clean all updateConversation calls to convo.commit()

pull/1377/head
Audric Ackermann 5 years ago
parent 1a5a0786a1
commit b050a3740d
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -641,9 +641,7 @@
this.set({ verified }); this.set({ verified });
// we don't await here because we don't need to wait for this to finish // we don't await here because we don't need to wait for this to finish
window.Signal.Data.updateConversation(this.id, this.attributes, { this.commit();
Conversation: Whisper.Conversation,
});
return; return;
} }
@ -706,9 +704,7 @@
} }
this.set({ verified }); this.set({ verified });
await window.Signal.Data.updateConversation(this.id, this.attributes, { await this.commit();
Conversation: Whisper.Conversation,
});
// Three situations result in a verification notice in the conversation: // Three situations result in a verification notice in the conversation:
// 1) The message came from an explicit verification in another client (not // 1) The message came from an explicit verification in another client (not
@ -813,16 +809,12 @@
secondaryStatus: newStatus, secondaryStatus: newStatus,
primaryDevicePubKey, primaryDevicePubKey,
}); });
await window.Signal.Data.updateConversation(this.id, this.attributes, { await this.commit();
Conversation: Whisper.Conversation,
});
} }
}, },
async updateGroupAdmins(groupAdmins) { async updateGroupAdmins(groupAdmins) {
this.set({ groupAdmins }); this.set({ groupAdmins });
await window.Signal.Data.updateConversation(this.id, this.attributes, { await this.commit();
Conversation: Whisper.Conversation,
});
}, },
isUnverified() { isUnverified() {
if (this.isPrivate()) { if (this.isPrivate()) {
@ -1307,9 +1299,7 @@
timestamp: now, timestamp: now,
isArchived: false, isArchived: false,
}); });
await window.Signal.Data.updateConversation(this.id, this.attributes, { await this.commit();
Conversation: Whisper.Conversation,
});
// We're offline! // We're offline!
if (!textsecure.messaging) { if (!textsecure.messaging) {
@ -1494,17 +1484,13 @@
this.set(lastMessageUpdate); this.set(lastMessageUpdate);
if (this.hasChanged()) { if (this.hasChanged()) {
await window.Signal.Data.updateConversation(this.id, this.attributes, { await this.commit();
Conversation: Whisper.Conversation,
});
} }
}, },
async setArchived(isArchived) { async setArchived(isArchived) {
this.set({ isArchived }); this.set({ isArchived });
await window.Signal.Data.updateConversation(this.id, this.attributes, { await this.commit();
Conversation: Whisper.Conversation,
});
}, },
async updateExpirationTimer( async updateExpirationTimer(
@ -1541,9 +1527,7 @@
const timestamp = (receivedAt || Date.now()) - 1; const timestamp = (receivedAt || Date.now()) - 1;
this.set({ expireTimer }); this.set({ expireTimer });
await window.Signal.Data.updateConversation(this.id, this.attributes, { await this.commit();
Conversation: Whisper.Conversation,
});
const message = this.messageCollection.add({ const message = this.messageCollection.add({
// Even though this isn't reflected to the user, we want to place the last seen // Even though this isn't reflected to the user, we want to place the last seen
@ -1636,9 +1620,7 @@
} }
if (this.get('sessionResetStatus') !== newStatus) { if (this.get('sessionResetStatus') !== newStatus) {
this.set({ sessionResetStatus: newStatus }); this.set({ sessionResetStatus: newStatus });
await window.Signal.Data.updateConversation(this.id, this.attributes, { await this.commit();
Conversation: Whisper.Conversation,
});
} }
}, },
async onSessionResetInitiated() { async onSessionResetInitiated() {
@ -1917,9 +1899,7 @@
this.set({ mentionedUs: false }); this.set({ mentionedUs: false });
} }
await window.Signal.Data.updateConversation(this.id, this.attributes, { await this.commit();
Conversation: Whisper.Conversation,
});
// If a message has errors, we don't want to send anything out about it. // If a message has errors, we don't want to send anything out about it.
// read syncs - let's wait for a client that really understands the message // read syncs - let's wait for a client that really understands the message
@ -1978,18 +1958,14 @@
} }
this.set({ nickname: trimmed }); this.set({ nickname: trimmed });
await window.Signal.Data.updateConversation(this.id, this.attributes, { await this.commit();
Conversation: Whisper.Conversation,
});
await this.updateProfileName(); await this.updateProfileName();
}, },
async setLokiProfile(newProfile) { async setLokiProfile(newProfile) {
if (!_.isEqual(this.get('profile'), newProfile)) { if (!_.isEqual(this.get('profile'), newProfile)) {
this.set({ profile: newProfile }); this.set({ profile: newProfile });
await window.Signal.Data.updateConversation(this.id, this.attributes, { await this.commit();
Conversation: Whisper.Conversation,
});
} }
// if set to null, it will show a placeholder with color and first letter // if set to null, it will show a placeholder with color and first letter
@ -2041,9 +2017,7 @@
channelId: newChannelId, channelId: newChannelId,
active_at: Date.now(), active_at: Date.now(),
}); });
await window.Signal.Data.updateConversation(this.id, this.attributes, { await this.commit();
Conversation: Whisper.Conversation,
});
} }
}, },
getPublicSource() { getPublicSource() {
@ -2080,9 +2054,7 @@
} }
if (this.get('lastPublicMessage') !== newLastMessageId) { if (this.get('lastPublicMessage') !== newLastMessageId) {
this.set({ lastPublicMessage: newLastMessageId }); this.set({ lastPublicMessage: newLastMessageId });
await window.Signal.Data.updateConversation(this.id, this.attributes, { await this.commit();
Conversation: Whisper.Conversation,
});
} }
}, },
isModerator(pubKey) { isModerator(pubKey) {
@ -2099,9 +2071,7 @@
// TODO: compare array properly // TODO: compare array properly
if (!_.isEqual(this.get('moderators'), moderators)) { if (!_.isEqual(this.get('moderators'), moderators)) {
this.set({ moderators }); this.set({ moderators });
await window.Signal.Data.updateConversation(this.id, this.attributes, { await this.commit();
Conversation: Whisper.Conversation,
});
} }
}, },
@ -2136,18 +2106,14 @@
const profileName = this.get('profileName'); const profileName = this.get('profileName');
if (profileName !== name) { if (profileName !== name) {
this.set({ profileName: name }); this.set({ profileName: name });
await window.Signal.Data.updateConversation(this.id, this.attributes, { await this.commit();
Conversation: Whisper.Conversation,
});
} }
}, },
async setGroupName(name) { async setGroupName(name) {
const profileName = this.get('name'); const profileName = this.get('name');
if (profileName !== name) { if (profileName !== name) {
this.set({ name }); this.set({ name });
await window.Signal.Data.updateConversation(this.id, this.attributes, { await this.commit();
Conversation: Whisper.Conversation,
});
} }
}, },
async setSubscriberCount(count) { async setSubscriberCount(count) {
@ -2166,18 +2132,14 @@
this.set({ name }); this.set({ name });
} }
// save // save
await window.Signal.Data.updateConversation(this.id, this.attributes, { await this.commit();
Conversation: Whisper.Conversation,
});
} }
}, },
async setProfileAvatar(avatar) { async setProfileAvatar(avatar) {
const profileAvatar = this.get('profileAvatar'); const profileAvatar = this.get('profileAvatar');
if (profileAvatar !== avatar) { if (profileAvatar !== avatar) {
this.set({ profileAvatar: avatar }); this.set({ profileAvatar: avatar });
await window.Signal.Data.updateConversation(this.id, this.attributes, { await this.commit();
Conversation: Whisper.Conversation,
});
} }
}, },
async setProfileKey(profileKey) { async setProfileKey(profileKey) {
@ -2194,9 +2156,7 @@
await this.deriveAccessKeyIfNeeded(); await this.deriveAccessKeyIfNeeded();
await window.Signal.Data.updateConversation(this.id, this.attributes, { await this.commit();
Conversation: Whisper.Conversation,
});
} }
}, },
@ -2426,9 +2386,7 @@
}); });
} }
await window.Signal.Data.updateConversation(this.id, this.attributes, { await this.commit();
Conversation: Whisper.Conversation,
});
}, },
getName() { getName() {

@ -50,11 +50,7 @@ exports.createConversation = async ({
unread: numMessages, unread: numMessages,
}); });
const conversationId = conversation.get('id'); const conversationId = conversation.get('id');
await Signal.Data.updateConversation( await conversation.commit();
conversationId,
conversation.attributes,
{ Conversation: Whisper.Conversation }
);
await Promise.all( await Promise.all(
range(0, numMessages).map(async index => { range(0, numMessages).map(async index => {

@ -1619,14 +1619,7 @@ class LokiPublicChannelAPI {
if (data.counts && Number.isInteger(data.counts.subscribers)) { if (data.counts && Number.isInteger(data.counts.subscribers)) {
this.conversation.setSubscriberCount(data.counts.subscribers); this.conversation.setSubscriberCount(data.counts.subscribers);
} }
await this.conversation.commit();
await window.Signal.Data.updateConversation(
this.conversation.id,
this.conversation.attributes,
{
Conversation: Whisper.Conversation,
}
);
} }
// get moderation actions // get moderation actions

@ -161,7 +161,6 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
const length = conversations.length; const length = conversations.length;
const listKey = 0; const listKey = 0;
// Note: conversations is not a known prop for List, but it is required to ensure that // Note: conversations is not a known prop for List, but it is required to ensure that
// it re-renders when our conversation data changes. Otherwise it would just render // it re-renders when our conversation data changes. Otherwise it would just render
// on startup and scroll. // on startup and scroll.

@ -16,9 +16,7 @@ async function onNoSession(ev: any) {
if (!convo.get('sessionRestoreSeen')) { if (!convo.get('sessionRestoreSeen')) {
convo.set({ sessionRestoreSeen: true }); convo.set({ sessionRestoreSeen: true });
await window.Signal.Data.updateConversation(convo.id, convo.attributes, { await convo.commit();
Conversation: Whisper.Conversation,
});
await SessionProtocol.sendSessionRequestIfNeeded(new PubKey(pubkey)); await SessionProtocol.sendSessionRequestIfNeeded(new PubKey(pubkey));
} else { } else {
@ -85,10 +83,7 @@ export async function onError(ev: any) {
if (ev.confirm) { if (ev.confirm) {
ev.confirm(); ev.confirm();
} }
await conversation.commit();
await window.Signal.Data.updateConversation(id, conversation.attributes, {
Conversation: Whisper.Conversation,
});
} }
throw error; throw error;

@ -409,10 +409,7 @@ async function onContactReceived(details: any) {
); );
conversation.set(newAttributes); conversation.set(newAttributes);
} }
await conversation.commit();
await window.Signal.Data.updateConversation(id, conversation.attributes, {
Conversation: Whisper.Conversation,
});
const { expireTimer } = details; const { expireTimer } = details;
const isValidExpireTimer = typeof expireTimer === 'number'; const isValidExpireTimer = typeof expireTimer === 'number';
if (isValidExpireTimer) { if (isValidExpireTimer) {

@ -193,7 +193,6 @@ export const _getLeftPaneLists = (
}; };
const contacts: Array<ConversationType> = filterToPrimary(allContacts); const contacts: Array<ConversationType> = filterToPrimary(allContacts);
return { return {
conversations, conversations,
archivedConversations, archivedConversations,

Loading…
Cancel
Save