feat: attempted to improve the accuracy of the start timer for disappear after send

pull/2660/head
William Grant 2 years ago
parent ee4aa333fc
commit 4ee440304c

@ -194,6 +194,7 @@ export function useTimerOptionsByMode(disappearingMessageMode?: string) {
return options.filter(option => {
return (
option.value === 10 || // 10 seconds (for testing)
option.value === 30 || // 30 seconds (for testing)
option.value === 43200 || // 12 hours
option.value === 86400 || // 1 day
option.value === 604800 || // 1 week
@ -204,6 +205,7 @@ export function useTimerOptionsByMode(disappearingMessageMode?: string) {
return options.filter(option => {
return (
option.value === 10 || // 10 seconds (for testing)
option.value === 30 || // 30 seconds (for testing)
option.value === 300 || // 5 minutes
option.value === 3600 || // 1 hour
option.value === 43200 || // 12 hours

@ -631,7 +631,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
if (message.get('groupInvitation')) {
const groupInvitation = message.get('groupInvitation');
const groupInvitMessage = new GroupInvitationMessage({
const groupInviteMessage = new GroupInvitationMessage({
identifier: id,
timestamp: sentAt,
name: groupInvitation.name,
@ -639,7 +639,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
expireTimer: this.get('expireTimer'),
});
// we need the return await so that errors are caught in the catch {}
await getMessageQueue().sendToPubKey(destinationPubkey, groupInvitMessage);
await getMessageQueue().sendToPubKey(destinationPubkey, groupInviteMessage);
return;
}
const chatMessagePrivate = new VisibleMessage(chatMessageParams);

@ -249,6 +249,11 @@ export async function handleSwarmDataMessage(
msgModel.get('sent_at')
);
msgModel.set('expirationStartTimestamp', expirationStartTimestamp);
console.log(
`WIP: handleSwarmDataMessage msgModel expirationStartTimestamp`,
msgModel.get('expirationStartTimestamp'),
msgModel.get('sent_at')
);
}
await handleSwarmMessage(

@ -242,9 +242,6 @@ async function handleRegularMessage(
message.set({ expireTimer: existingExpireTimer });
}
// Expire timer updates are now explicit.
// We don't handle an expire timer from a incoming message except if it is an ExpireTimerUpdate message.
const ourIdInThisConversation =
getUsBlindedInThatServer(conversation.id) || UserUtils.getOurPubKeyStrFromCache();

@ -125,18 +125,21 @@ async function handleMessageSentSuccess(
sentTo = _.union(sentTo, [sentMessage.device]);
if (fetchedMessage.get('expirationType') === 'deleteAfterSend') {
const expirationStartTimestamp = setExpirationStartTimestamp(fetchedMessage, 'deleteAfterSend');
fetchedMessage.set('expirationStartTimestamp', expirationStartTimestamp);
}
fetchedMessage.set({
sent_to: sentTo,
sent: true,
// TODO do we need to use this for the timestamp for the delete after send logic
sent_at: effectiveTimestamp,
});
if (fetchedMessage.get('expirationType') === 'deleteAfterSend') {
const expirationStartTimestamp = setExpirationStartTimestamp(
fetchedMessage,
'deleteAfterSend',
effectiveTimestamp
);
fetchedMessage.set('expirationStartTimestamp', expirationStartTimestamp);
}
await fetchedMessage.commit();
fetchedMessage.getConversation()?.updateLastMessage();
}

@ -208,11 +208,20 @@ export function setExpirationStartTimestamp(
}
if (mode === 'deleteAfterRead') {
window.log.info(`WIP: we set the start timetamp for a delete after read message`, message);
window.log.info(
`WIP: setExpirationStartTimestamp we set the start timetamp for a delete after read message`,
message
);
} else if (mode === 'deleteAfterSend') {
window.log.info(`WIP: we set the start timetamp for a delete after send message`, message);
window.log.info(
`WIP: setExpirationStartTimestamp we set the start timetamp for a delete after send message`,
message
);
} else {
console.log(`WIP: Invalid disappearing message mode set, ignoring this message`, message);
console.log(
`WIP: setExpirationStartTimestamp Invalid disappearing message mode set, ignoring this message`,
message
);
return;
}

Loading…
Cancel
Save