Rename "view sync" to "view once open sync"
This commit is contained in:
parent
fd70173e3e
commit
07f0efc45f
6 changed files with 43 additions and 39 deletions
|
@ -50,7 +50,7 @@ import {
|
|||
MessageEventData,
|
||||
ReadEvent,
|
||||
ConfigurationEvent,
|
||||
ViewSyncEvent,
|
||||
ViewOnceOpenSyncEvent,
|
||||
MessageRequestResponseEvent,
|
||||
FetchLatestEvent,
|
||||
KeysEvent,
|
||||
|
@ -77,7 +77,7 @@ import {
|
|||
import { MessageRequests } from './messageModifiers/MessageRequests';
|
||||
import { Reactions } from './messageModifiers/Reactions';
|
||||
import { ReadSyncs } from './messageModifiers/ReadSyncs';
|
||||
import { ViewSyncs } from './messageModifiers/ViewSyncs';
|
||||
import { ViewOnceOpenSyncs } from './messageModifiers/ViewOnceOpenSyncs';
|
||||
import {
|
||||
SendStateByConversationId,
|
||||
SendStatus,
|
||||
|
@ -2208,8 +2208,8 @@ export async function startApp(): Promise<void> {
|
|||
queuedEventListener(onStickerPack)
|
||||
);
|
||||
messageReceiver.addEventListener(
|
||||
'viewSync',
|
||||
queuedEventListener(onViewSync)
|
||||
'viewOnceOpenSync',
|
||||
queuedEventListener(onViewOnceOpenSync)
|
||||
);
|
||||
messageReceiver.addEventListener(
|
||||
'messageRequestResponse',
|
||||
|
@ -3633,19 +3633,19 @@ export async function startApp(): Promise<void> {
|
|||
window.log.warn('background onError: Doing nothing with incoming error');
|
||||
}
|
||||
|
||||
async function onViewSync(ev: ViewSyncEvent) {
|
||||
async function onViewOnceOpenSync(ev: ViewOnceOpenSyncEvent) {
|
||||
ev.confirm();
|
||||
|
||||
const { source, sourceUuid, timestamp } = ev;
|
||||
window.log.info(`view sync ${source} ${timestamp}`);
|
||||
window.log.info(`view once open sync ${source} ${timestamp}`);
|
||||
|
||||
const sync = ViewSyncs.getSingleton().add({
|
||||
const sync = ViewOnceOpenSyncs.getSingleton().add({
|
||||
source,
|
||||
sourceUuid,
|
||||
timestamp,
|
||||
});
|
||||
|
||||
ViewSyncs.getSingleton().onSync(sync);
|
||||
ViewOnceOpenSyncs.getSingleton().onSync(sync);
|
||||
}
|
||||
|
||||
async function onFetchLatestSync(ev: FetchLatestEvent) {
|
||||
|
|
|
@ -6,26 +6,26 @@
|
|||
import { Collection, Model } from 'backbone';
|
||||
import { MessageModel } from '../models/messages';
|
||||
|
||||
type ViewSyncAttributesType = {
|
||||
type ViewOnceOpenSyncAttributesType = {
|
||||
source?: string;
|
||||
sourceUuid: string;
|
||||
timestamp: number;
|
||||
};
|
||||
|
||||
class ViewSyncModel extends Model<ViewSyncAttributesType> {}
|
||||
class ViewOnceOpenSyncModel extends Model<ViewOnceOpenSyncAttributesType> {}
|
||||
|
||||
let singleton: ViewSyncs | undefined;
|
||||
let singleton: ViewOnceOpenSyncs | undefined;
|
||||
|
||||
export class ViewSyncs extends Collection<ViewSyncModel> {
|
||||
static getSingleton(): ViewSyncs {
|
||||
export class ViewOnceOpenSyncs extends Collection<ViewOnceOpenSyncModel> {
|
||||
static getSingleton(): ViewOnceOpenSyncs {
|
||||
if (!singleton) {
|
||||
singleton = new ViewSyncs();
|
||||
singleton = new ViewOnceOpenSyncs();
|
||||
}
|
||||
|
||||
return singleton;
|
||||
}
|
||||
|
||||
forMessage(message: MessageModel): ViewSyncModel | null {
|
||||
forMessage(message: MessageModel): ViewOnceOpenSyncModel | null {
|
||||
const syncBySourceUuid = this.find(item => {
|
||||
return (
|
||||
item.get('sourceUuid') === message.get('sourceUuid') &&
|
||||
|
@ -33,7 +33,7 @@ export class ViewSyncs extends Collection<ViewSyncModel> {
|
|||
);
|
||||
});
|
||||
if (syncBySourceUuid) {
|
||||
window.log.info('Found early view sync for message');
|
||||
window.log.info('Found early view once open sync for message');
|
||||
this.remove(syncBySourceUuid);
|
||||
return syncBySourceUuid;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ export class ViewSyncs extends Collection<ViewSyncModel> {
|
|||
);
|
||||
});
|
||||
if (syncBySource) {
|
||||
window.log.info('Found early view sync for message');
|
||||
window.log.info('Found early view once open sync for message');
|
||||
this.remove(syncBySource);
|
||||
return syncBySource;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ export class ViewSyncs extends Collection<ViewSyncModel> {
|
|||
return null;
|
||||
}
|
||||
|
||||
async onSync(sync: ViewSyncModel): Promise<void> {
|
||||
async onSync(sync: ViewOnceOpenSyncModel): Promise<void> {
|
||||
try {
|
||||
const messages = await window.Signal.Data.getMessagesBySentAt(
|
||||
sync.get('timestamp'),
|
||||
|
@ -80,7 +80,7 @@ export class ViewSyncs extends Collection<ViewSyncModel> {
|
|||
const syncSourceUuid = sync.get('sourceUuid');
|
||||
const syncTimestamp = sync.get('timestamp');
|
||||
const wasMessageFound = Boolean(found);
|
||||
window.log.info('Receive view sync:', {
|
||||
window.log.info('Receive view once open sync:', {
|
||||
syncSource,
|
||||
syncSourceUuid,
|
||||
syncTimestamp,
|
||||
|
@ -92,12 +92,12 @@ export class ViewSyncs extends Collection<ViewSyncModel> {
|
|||
}
|
||||
|
||||
const message = window.MessageController.register(found.id, found);
|
||||
await message.markViewed({ fromSync: true });
|
||||
await message.markViewOnceMessageViewed({ fromSync: true });
|
||||
|
||||
this.remove(sync);
|
||||
} catch (error) {
|
||||
window.log.error(
|
||||
'ViewSyncs.onSync error:',
|
||||
'ViewOnceOpenSyncs.onSync error:',
|
||||
error && error.stack ? error.stack : error
|
||||
);
|
||||
}
|
|
@ -103,7 +103,7 @@ import {
|
|||
import { Deletes } from '../messageModifiers/Deletes';
|
||||
import { Reactions } from '../messageModifiers/Reactions';
|
||||
import { ReadSyncs } from '../messageModifiers/ReadSyncs';
|
||||
import { ViewSyncs } from '../messageModifiers/ViewSyncs';
|
||||
import { ViewOnceOpenSyncs } from '../messageModifiers/ViewOnceOpenSyncs';
|
||||
import * as AttachmentDownloads from '../messageModifiers/AttachmentDownloads';
|
||||
import * as LinkPreview from '../types/LinkPreview';
|
||||
import { SignalService as Proto } from '../protobuf';
|
||||
|
@ -829,18 +829,20 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
return true;
|
||||
}
|
||||
|
||||
async markViewed(options?: { fromSync?: boolean }): Promise<void> {
|
||||
async markViewOnceMessageViewed(options?: {
|
||||
fromSync?: boolean;
|
||||
}): Promise<void> {
|
||||
const { fromSync } = options || {};
|
||||
|
||||
if (!this.isValidTapToView()) {
|
||||
window.log.warn(
|
||||
`markViewed: Message ${this.idForLogging()} is not a valid tap to view message!`
|
||||
`markViewOnceMessageViewed: Message ${this.idForLogging()} is not a valid tap to view message!`
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (this.isErased()) {
|
||||
window.log.warn(
|
||||
`markViewed: Message ${this.idForLogging()} is already erased!`
|
||||
`markViewOnceMessageViewed: Message ${this.idForLogging()} is already erased!`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
@ -867,7 +869,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
|
||||
if (window.ConversationController.areWePrimaryDevice()) {
|
||||
window.log.warn(
|
||||
'markViewed: We are primary device; not sending view sync'
|
||||
'markViewOnceMessageViewed: We are primary device; not sending view once open sync'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
@ -3282,11 +3284,13 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
}
|
||||
}
|
||||
|
||||
// Check for out-of-order view syncs
|
||||
// Check for out-of-order view once open syncs
|
||||
if (type === 'incoming' && isTapToView(message.attributes)) {
|
||||
const viewSync = ViewSyncs.getSingleton().forMessage(message);
|
||||
if (viewSync) {
|
||||
await message.markViewed({ fromSync: true });
|
||||
const viewOnceOpenSync = ViewOnceOpenSyncs.getSingleton().forMessage(
|
||||
message
|
||||
);
|
||||
if (viewOnceOpenSync) {
|
||||
await message.markViewOnceMessageViewed({ fromSync: true });
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ import {
|
|||
RetryRequestEvent,
|
||||
ReadEvent,
|
||||
ConfigurationEvent,
|
||||
ViewSyncEvent,
|
||||
ViewOnceOpenSyncEvent,
|
||||
MessageRequestResponseEvent,
|
||||
FetchLatestEvent,
|
||||
KeysEvent,
|
||||
|
@ -2337,7 +2337,7 @@ class MessageReceiverInner extends EventTarget {
|
|||
) {
|
||||
window.log.info('got view once open sync message');
|
||||
|
||||
const ev = new ViewSyncEvent(
|
||||
const ev = new ViewOnceOpenSyncEvent(
|
||||
{
|
||||
source: dropNull(sync.sender),
|
||||
sourceUuid: sync.senderUuid
|
||||
|
@ -2755,8 +2755,8 @@ export default class MessageReceiver {
|
|||
): void;
|
||||
|
||||
public addEventListener(
|
||||
name: 'viewSync',
|
||||
handler: (ev: ViewSyncEvent) => void
|
||||
name: 'viewOnceOpenSync',
|
||||
handler: (ev: ViewOnceOpenSyncEvent) => void
|
||||
): void;
|
||||
|
||||
public addEventListener(
|
||||
|
|
|
@ -237,13 +237,13 @@ export class ConfigurationEvent extends ConfirmableEvent {
|
|||
}
|
||||
}
|
||||
|
||||
export type ViewSyncOptions = {
|
||||
export type ViewOnceOpenSyncOptions = {
|
||||
source?: string;
|
||||
sourceUuid?: string;
|
||||
timestamp?: number;
|
||||
};
|
||||
|
||||
export class ViewSyncEvent extends ConfirmableEvent {
|
||||
export class ViewOnceOpenSyncEvent extends ConfirmableEvent {
|
||||
public readonly source?: string;
|
||||
|
||||
public readonly sourceUuid?: string;
|
||||
|
@ -251,10 +251,10 @@ export class ViewSyncEvent extends ConfirmableEvent {
|
|||
public readonly timestamp?: number;
|
||||
|
||||
constructor(
|
||||
{ source, sourceUuid, timestamp }: ViewSyncOptions,
|
||||
{ source, sourceUuid, timestamp }: ViewOnceOpenSyncOptions,
|
||||
confirm: ConfirmCallback
|
||||
) {
|
||||
super('viewSync', confirm);
|
||||
super('viewOnceOpenSync', confirm);
|
||||
|
||||
this.source = source;
|
||||
this.sourceUuid = sourceUuid;
|
||||
|
|
|
@ -2907,7 +2907,7 @@ Whisper.ConversationView = Whisper.View.extend({
|
|||
path: tempPath,
|
||||
};
|
||||
|
||||
await message.markViewed();
|
||||
await message.markViewOnceMessageViewed();
|
||||
|
||||
const closeLightbox = async () => {
|
||||
if (!this.lightboxView) {
|
||||
|
|
Loading…
Reference in a new issue