From 95a946b8307d86778ccbf6308a2e7a8e0a7abc9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Iv=C3=A1n=20Vieitez=20Parra?= <3857362+corrideat@users.noreply.github.com> Date: Fri, 20 Oct 2023 18:18:23 +0200 Subject: [PATCH 1/3] Fix inability to join after sharer signs out --- shared/domains/chelonia/internals.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/domains/chelonia/internals.js b/shared/domains/chelonia/internals.js index 18b1362d91..d6c2116268 100644 --- a/shared/domains/chelonia/internals.js +++ b/shared/domains/chelonia/internals.js @@ -1242,7 +1242,7 @@ export default (sbp('sbp/selectors/register', { }): string[]) const eventsToReinjest = [] -const reprocessDebounced = debounce((contractID) => sbp('chelonia/contract/sync', contractID), 1000) +const reprocessDebounced = debounce((contractID) => sbp('chelonia/contract/sync', contractID, { force: true }), 1000) const handleEvent = { async addMessageToDB (message: GIMessage) { From 2a78c44f1569565abb45604eda26a9cf96d9f7ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Iv=C3=A1n=20Vieitez=20Parra?= <3857362+corrideat@users.noreply.github.com> Date: Fri, 20 Oct 2023 20:49:39 +0200 Subject: [PATCH 2/3] Fix infinite re-subscription due to foreign keys --- shared/domains/chelonia/internals.js | 35 ++++++++++++++++++++++++++-- shared/domains/chelonia/utils.js | 2 +- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/shared/domains/chelonia/internals.js b/shared/domains/chelonia/internals.js index d6c2116268..30b3bb1562 100644 --- a/shared/domains/chelonia/internals.js +++ b/shared/domains/chelonia/internals.js @@ -859,7 +859,20 @@ export default (sbp('sbp/selectors/register', { // For each pending watch operation, queue a synchronization event in the // respective contract queue Object.entries(pendingWatch).forEach(([contractID, keys]) => { - if (!Array.isArray(keys) || keys.length === 0) return + if ( + !Array.isArray(keys) || + // Check that the keys exist and haven't been revoked + // $FlowFixMe[incompatible-use] + !keys.reduce((acc, [, id]) => { + return acc || has(externalContractState._vm.authorizedKeys, id) + }, false) + ) { + console.info('[chelonia/private/watchForeignKeys]: Skipping as none of the keys to watch exist', { + externalContractID, + contractID + }) + return + } sbp('okTurtles.eventQueue/queueEvent', contractID, ['chelonia/private/in/syncContractAndWatchKeys', contractID, externalContractID]).catch((e) => { console.error(`Error at syncContractAndWatchKeys for contractID ${contractID} and externalContractID ${externalContractID}`, e) @@ -871,7 +884,25 @@ export default (sbp('sbp/selectors/register', { const externalContractState = rootState[externalContractID] const pendingWatch = externalContractState?._vm?.pendingWatch?.[contractID]?.splice(0) - if (!Array.isArray(pendingWatch) || pendingWatch.length === 0) return + // We duplicate the check in 'chelonia/private/watchForeignKeys' because + // new events may have been received in the meantime. This avoids + // unnecessarily subscribing to the contract + if ( + !Array.isArray(pendingWatch) || + // Check that the keys exist and haven't been revoked + !pendingWatch.reduce((acc, [, id]) => { + return acc || ( + has(externalContractState._vm.authorizedKeys, id) && + findKeyIdByName(externalContractState, externalContractState._vm.authorizedKeys[id].name) != null + ) + }, false) + ) { + console.info('[chelonia/private/syncContractAndWatchKeys]: Skipping as none of the keys to watch exist', { + externalContractID, + contractID + }) + return + } await sbp('chelonia/private/in/syncContract', contractID) diff --git a/shared/domains/chelonia/utils.js b/shared/domains/chelonia/utils.js index bfb09f8388..2dc1f83d7e 100644 --- a/shared/domains/chelonia/utils.js +++ b/shared/domains/chelonia/utils.js @@ -351,7 +351,7 @@ export const keyAdditionProcessor = function (keys: (GIKey | EncryptedData !!((key: any): GIKey).foreignKey).forEach((key: GIKey) => { + Object.values((state._vm.authorizedKeys: { [x: string]: GIKey })).filter((key) => !!((key: any): GIKey).foreignKey && findKeyIdByName(state, ((key: any): GIKey).name) != null).forEach((key: GIKey) => { const foreignKey = String(key.foreignKey) const fkUrl = new URL(foreignKey) const foreignContract = fkUrl.pathname From 26d51791cdab3b334e6d428deb250cab932b842b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Iv=C3=A1n=20Vieitez=20Parra?= <3857362+corrideat@users.noreply.github.com> Date: Fri, 20 Oct 2023 21:41:44 +0200 Subject: [PATCH 3/3] Fix undefined in vmInvites --- .../views/containers/group-settings/InvitationsTable.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/views/containers/group-settings/InvitationsTable.vue b/frontend/views/containers/group-settings/InvitationsTable.vue index 724a58042e..cfc0a02356 100644 --- a/frontend/views/containers/group-settings/InvitationsTable.vue +++ b/frontend/views/containers/group-settings/InvitationsTable.vue @@ -27,7 +27,7 @@ page-section.c-section(:title='L("Invite links")') transition-group(name='slidedown' tag='tbody') tr( v-for='(item, index) in invitesToShow' - :key='item.inviteSecret' + :key='index' ) td.c-name | {{ item.invitee }} @@ -167,11 +167,11 @@ export default ({ 'currentGroupId' ]), invitesToShow () { - const invites = this.currentGroupState.invites - const vmInvites = this.currentGroupState._vm.invites - + const vmInvites = this.currentGroupState._vm?.invites if (!vmInvites) { return [] } + const invites = this.currentGroupState.invites || {} + const invitesList = Object.entries(vmInvites) .map(([id, invite]) => [id, { ...invite, creator: invites[id]?.creator, invitee: invites[id]?.invitee }]) .filter(([, invite]) => invite.creator === INVITE_INITIAL_CREATOR || invite.creator === this.ourUsername)