Onboarding story

This commit is contained in:
Josh Perez 2022-11-08 21:38:19 -05:00 committed by GitHub
parent 94f318ea08
commit 19a42ed719
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 725 additions and 143 deletions

View file

@ -0,0 +1,48 @@
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { DAY } from './durations';
import { getMessageById } from '../messages/getMessageById';
import { isNotNil } from './isNotNil';
import { markViewed } from '../services/MessageUpdater';
import { storageServiceUploadJob } from '../services/storage';
export async function markOnboardingStoryAsRead(): Promise<void> {
const existingOnboardingStoryMessageIds = window.storage.get(
'existingOnboardingStoryMessageIds'
);
if (!existingOnboardingStoryMessageIds) {
return;
}
const messages = await Promise.all(
existingOnboardingStoryMessageIds.map(getMessageById)
);
const storyReadDate = Date.now();
const messageAttributes = messages
.map(message => {
if (!message) {
return;
}
message.set({
expireTimer: DAY,
});
message.set(markViewed(message.attributes, storyReadDate));
return message.attributes;
})
.filter(isNotNil);
window.Signal.Data.saveMessages(messageAttributes, {
ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(),
});
window.storage.put('hasViewedOnboardingStory', true);
storageServiceUploadJob();
}