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
2 changed files with 22 additions and 7 deletions

View File

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

View File

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