Use timestamp instead of full model for tap-to-view age outs
This commit is contained in:
parent
80da8bb47b
commit
f3e207d0b0
4 changed files with 15 additions and 30 deletions
|
@ -50,16 +50,11 @@
|
||||||
const HOUR = 60 * MINUTE;
|
const HOUR = 60 * MINUTE;
|
||||||
const THIRTY_DAYS = 30 * 24 * HOUR;
|
const THIRTY_DAYS = 30 * 24 * HOUR;
|
||||||
|
|
||||||
const toAgeOut = await window.Signal.Data.getNextTapToViewMessageToAgeOut({
|
const receivedAt = await window.Signal.Data.getNextTapToViewMessageTimestampToAgeOut();
|
||||||
Message: Whisper.Message,
|
if (!receivedAt) {
|
||||||
});
|
|
||||||
|
|
||||||
if (!toAgeOut) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const receivedAt =
|
|
||||||
toAgeOut.get('received_at_ms') || toAgeOut.get('received_at');
|
|
||||||
const nextCheck = receivedAt + THIRTY_DAYS;
|
const nextCheck = receivedAt + THIRTY_DAYS;
|
||||||
|
|
||||||
Whisper.TapToViewMessagesListener.nextCheck = nextCheck;
|
Whisper.TapToViewMessagesListener.nextCheck = nextCheck;
|
||||||
|
|
|
@ -188,7 +188,7 @@ const dataInterface: ClientInterface = {
|
||||||
getExpiredMessages,
|
getExpiredMessages,
|
||||||
getOutgoingWithoutExpiresAt,
|
getOutgoingWithoutExpiresAt,
|
||||||
getNextExpiringMessage,
|
getNextExpiringMessage,
|
||||||
getNextTapToViewMessageToAgeOut,
|
getNextTapToViewMessageTimestampToAgeOut,
|
||||||
getTapToViewMessagesNeedingErase,
|
getTapToViewMessagesNeedingErase,
|
||||||
getOlderMessagesByConversation,
|
getOlderMessagesByConversation,
|
||||||
getNewerMessagesByConversation,
|
getNewerMessagesByConversation,
|
||||||
|
@ -1324,17 +1324,8 @@ async function getNextExpiringMessage({
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getNextTapToViewMessageToAgeOut({
|
async function getNextTapToViewMessageTimestampToAgeOut() {
|
||||||
Message,
|
return channels.getNextTapToViewMessageTimestampToAgeOut();
|
||||||
}: {
|
|
||||||
Message: typeof MessageModel;
|
|
||||||
}) {
|
|
||||||
const message = await channels.getNextTapToViewMessageToAgeOut();
|
|
||||||
if (!message) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Message(message);
|
|
||||||
}
|
}
|
||||||
async function getTapToViewMessagesNeedingErase({
|
async function getTapToViewMessagesNeedingErase({
|
||||||
MessageCollection,
|
MessageCollection,
|
||||||
|
|
|
@ -229,6 +229,7 @@ export type DataInterface = {
|
||||||
obsoleteId: string,
|
obsoleteId: string,
|
||||||
currentId: string
|
currentId: string
|
||||||
) => Promise<void>;
|
) => Promise<void>;
|
||||||
|
getNextTapToViewMessageTimestampToAgeOut: () => Promise<undefined | number>;
|
||||||
|
|
||||||
getUnprocessedCount: () => Promise<number>;
|
getUnprocessedCount: () => Promise<number>;
|
||||||
getAllUnprocessed: () => Promise<Array<UnprocessedType>>;
|
getAllUnprocessed: () => Promise<Array<UnprocessedType>>;
|
||||||
|
@ -359,7 +360,6 @@ export type ServerInterface = DataInterface & {
|
||||||
ourConversationId: string;
|
ourConversationId: string;
|
||||||
}) => Promise<MessageType | undefined>;
|
}) => Promise<MessageType | undefined>;
|
||||||
getNextExpiringMessage: () => Promise<MessageType | undefined>;
|
getNextExpiringMessage: () => Promise<MessageType | undefined>;
|
||||||
getNextTapToViewMessageToAgeOut: () => Promise<MessageType | undefined>;
|
|
||||||
getOutgoingWithoutExpiresAt: () => Promise<Array<MessageType>>;
|
getOutgoingWithoutExpiresAt: () => Promise<Array<MessageType>>;
|
||||||
getTapToViewMessagesNeedingErase: () => Promise<Array<MessageType>>;
|
getTapToViewMessagesNeedingErase: () => Promise<Array<MessageType>>;
|
||||||
getUnreadCountForConversation: (conversationId: string) => Promise<number>;
|
getUnreadCountForConversation: (conversationId: string) => Promise<number>;
|
||||||
|
@ -497,9 +497,6 @@ export type ClientInterface = DataInterface & {
|
||||||
getNextExpiringMessage: (options: {
|
getNextExpiringMessage: (options: {
|
||||||
Message: typeof MessageModel;
|
Message: typeof MessageModel;
|
||||||
}) => Promise<MessageModel | null>;
|
}) => Promise<MessageModel | null>;
|
||||||
getNextTapToViewMessageToAgeOut: (options: {
|
|
||||||
Message: typeof MessageModel;
|
|
||||||
}) => Promise<MessageModel | null>;
|
|
||||||
getOutgoingWithoutExpiresAt: (options: {
|
getOutgoingWithoutExpiresAt: (options: {
|
||||||
MessageCollection: typeof MessageModelCollectionType;
|
MessageCollection: typeof MessageModelCollectionType;
|
||||||
}) => Promise<MessageModelCollectionType>;
|
}) => Promise<MessageModelCollectionType>;
|
||||||
|
|
|
@ -178,7 +178,7 @@ const dataInterface: ServerInterface = {
|
||||||
getExpiredMessages,
|
getExpiredMessages,
|
||||||
getOutgoingWithoutExpiresAt,
|
getOutgoingWithoutExpiresAt,
|
||||||
getNextExpiringMessage,
|
getNextExpiringMessage,
|
||||||
getNextTapToViewMessageToAgeOut,
|
getNextTapToViewMessageTimestampToAgeOut,
|
||||||
getTapToViewMessagesNeedingErase,
|
getTapToViewMessagesNeedingErase,
|
||||||
getOlderMessagesByConversation,
|
getOlderMessagesByConversation,
|
||||||
getNewerMessagesByConversation,
|
getNewerMessagesByConversation,
|
||||||
|
@ -3924,11 +3924,11 @@ async function getNextExpiringMessage(): Promise<MessageType | undefined> {
|
||||||
return jsonToObject(rows[0].json);
|
return jsonToObject(rows[0].json);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getNextTapToViewMessageToAgeOut(): Promise<
|
async function getNextTapToViewMessageTimestampToAgeOut(): Promise<
|
||||||
MessageType | undefined
|
undefined | number
|
||||||
> {
|
> {
|
||||||
const db = getInstance();
|
const db = getInstance();
|
||||||
const rows = db
|
const row = db
|
||||||
.prepare<EmptyQuery>(
|
.prepare<EmptyQuery>(
|
||||||
`
|
`
|
||||||
SELECT json FROM messages
|
SELECT json FROM messages
|
||||||
|
@ -3939,13 +3939,15 @@ async function getNextTapToViewMessageToAgeOut(): Promise<
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
`
|
`
|
||||||
)
|
)
|
||||||
.all();
|
.get();
|
||||||
|
|
||||||
if (!rows || rows.length < 1) {
|
if (!row) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
return jsonToObject(rows[0].json);
|
const data = jsonToObject(row.json);
|
||||||
|
const result = data.received_at_ms || data.received_at;
|
||||||
|
return isNormalNumber(result) ? result : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getTapToViewMessagesNeedingErase(): Promise<Array<MessageType>> {
|
async function getTapToViewMessagesNeedingErase(): Promise<Array<MessageType>> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue