Continue to mark story read if markOnboardingStoryAsRead didn't do it

This commit is contained in:
Scott Nonnenberg 2023-04-18 08:35:29 -07:00 committed by GitHub
parent 5395741f11
commit 7db16c4f0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 7 deletions

View file

@ -396,8 +396,13 @@ function markStoryRead(
const isSignalOnboardingStory = message.get('sourceUuid') === SIGNAL_ACI;
if (isSignalOnboardingStory) {
drop(markOnboardingStoryAsRead());
return;
const updatedMessages = await markOnboardingStoryAsRead();
if (updatedMessages) {
return;
}
log.warn(
'markStoryRead: Failed to mark onboarding story read normally; failing over'
);
}
const storyReadDate = Date.now();
@ -421,11 +426,17 @@ function markStoryRead(
};
const viewSyncs: Array<SyncType> = [viewedReceipt];
if (!window.ConversationController.areWePrimaryDevice()) {
if (
!isSignalOnboardingStory &&
!window.ConversationController.areWePrimaryDevice()
) {
drop(viewSyncJobQueue.add({ viewSyncs }));
}
if (window.Events.getStoryViewReceiptsEnabled()) {
if (
!isSignalOnboardingStory &&
window.Events.getStoryViewReceiptsEnabled()
) {
drop(
conversationJobQueue.add({
type: conversationQueueJobEnum.enum.Receipts,

View file

@ -8,14 +8,14 @@ import { DurationInSeconds } from './durations';
import { markViewed } from '../services/MessageUpdater';
import { storageServiceUploadJob } from '../services/storage';
export async function markOnboardingStoryAsRead(): Promise<void> {
export async function markOnboardingStoryAsRead(): Promise<boolean> {
const existingOnboardingStoryMessageIds = window.storage.get(
'existingOnboardingStoryMessageIds'
);
if (!existingOnboardingStoryMessageIds) {
log.warn('markOnboardingStoryAsRead: no existing messages');
return;
return false;
}
const messages = await Promise.all(
@ -40,7 +40,9 @@ export async function markOnboardingStoryAsRead(): Promise<void> {
})
.filter(isNotNil);
log.info('markOnboardingStoryAsRead: marked viewed');
log.info(
`markOnboardingStoryAsRead: marked ${messageAttributes.length} viewed`
);
await window.Signal.Data.saveMessages(messageAttributes, {
ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(),
@ -49,4 +51,6 @@ export async function markOnboardingStoryAsRead(): Promise<void> {
await window.storage.put('hasViewedOnboardingStory', true);
storageServiceUploadJob();
return true;
}