Onboarding story
This commit is contained in:
parent
94f318ea08
commit
19a42ed719
42 changed files with 725 additions and 143 deletions
48
ts/util/markOnboardingStoryAsRead.ts
Normal file
48
ts/util/markOnboardingStoryAsRead.ts
Normal 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();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue