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