Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure we sync any identity contracts we haven't synced upon login #1763

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions frontend/controller/actions/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,16 @@ export default (sbp('sbp/selectors/register', {
})
}

// NOTE: sync identity contracts which are out of sync after joining group
const missingIDs = (await Promise.all(
Object.keys(state.profiles)
.map(username => sbp('namespace/lookup', username))
)).filter(id => !rootState[id] && !sbp('chelonia/contract/isSyncing', id))
if (missingIDs.length > 0) {
console.info('found unsynced identity contracts to sync:', missingIDs)
await sbp('chelonia/contract/sync', missingIDs)
}

sbp('okTurtles.data/set', 'JOINING_GROUP-' + params.contractID, false)
// We have already sent a key request that hasn't been answered. We cannot
// do much at this point, so we do nothing.
Expand Down
5 changes: 1 addition & 4 deletions frontend/controller/actions/identity.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,7 @@ export default (sbp('sbp/selectors/register', {
const additionalIdentityContractIDs = await Promise.all(chatRoomUsers.filter(username => {
return getters.ourUsername !== username && !getters.ourContacts.includes(username)
}).map(username => sbp('namespace/lookup', username)))

for (const identityContractID of additionalIdentityContractIDs) {
await sbp('chelonia/contract/sync', identityContractID)
}
Silver-IT marked this conversation as resolved.
Show resolved Hide resolved
await sbp('chelonia/contract/sync', additionalIdentityContractIDs)

// NOTE: users could notice that they leave the group by someone else when they log in
if (!state.currentGroupId) {
Expand Down