Skip to content

Commit

Permalink
Remove await from contracts identity.js and other small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
corrideat committed Jan 23, 2024
1 parent cd04f0c commit c7de2e8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion frontend/controller/actions/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export default (sbp('sbp/selectors/register', {
// all of the steps for joining in the past, but we've then been removed
// while we were offline. In this case, we should *not* re-join
// automatically, even if we have a valid invitation secret and are
// technically able to. However, if the previous situation we *should*
// technically able to. However, in the previous situation we *should*
// attempt to rejoin if the action was user-initiated.
const hasKeyShareBeenRespondedBy = sbp('chelonia/contract/hasKeyShareBeenRespondedBy', userID, params.contractID, params.reference)

Expand Down
5 changes: 3 additions & 2 deletions frontend/controller/actions/identity.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,11 @@ export default (sbp('sbp/selectors/register', {
'gi.actions/identity/logout': async function () {
try {
const state = sbp('state/vuex/state')
// wait for any pending sync operations to finish before saving
console.info('logging out, waiting for any events to finish...')
await sbp('okTurtles.eventQueue/queueEvent', 'encrypted-action', () => {})
await sbp('chelonia/reset', async () => {
// wait for any pending sync operations to finish before saving,
// including those that side-effects might have sent
await sbp('okTurtles.eventQueue/queueEvent', 'encrypted-action', () => {})
// See comment below for 'gi.db/settings/delete'
await sbp('state/vuex/save')

Expand Down
6 changes: 4 additions & 2 deletions frontend/model/contracts/identity.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ sbp('chelonia/defineContract', {
Vue.delete(state.groups, groupContractID)
},
sideEffect ({ meta, data, contractID, innerSigningContractID }, { state }) {
sbp('chelonia/queueInvocation', contractID, async () => {
sbp('chelonia/queueInvocation', contractID, () => {
const rootState = sbp('state/vuex/state')
const state = rootState[contractID]

Expand All @@ -239,9 +239,11 @@ sbp('chelonia/defineContract', {
}

if (has(rootState.contracts, groupContractID)) {
await sbp('gi.actions/group/removeOurselves', {
sbp('gi.actions/group/removeOurselves', {
contractID: groupContractID,
data: {}
}).catch(e => {
console.error(`[gi.contracts/identity/leaveGroup/sideEffect] Error sending /removeOurselvs action to group ${data.groupContractID}`, e)
})
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/model/contracts/manifests.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"manifests": {
"gi.contracts/chatroom": "21XWnNMgR144Bw53R99pzoqhdg7n6VdEE1o4PWdoN5mdrGQSTT",
"gi.contracts/group": "21XWnNRJJiwLyc5Ldgo5eTaDaJ8zSp74pYFB9JV2yCDjGa3gvA",
"gi.contracts/identity": "21XWnNQDZ9PgvvLJTRNVxxbKmAiUtWu9z2tXpFhaRvEckM8Peo"
"gi.contracts/identity": "21XWnNWbBF1cz7VSRKffrmppQuPNncZdbmbN2Zf7bdmRSMgGCx"
}
}

0 comments on commit c7de2e8

Please sign in to comment.