From 201a3637581810174161c05b3c0d4e5280c3cec5 Mon Sep 17 00:00:00 2001 From: Jonas Date: Thu, 14 Mar 2024 12:24:36 +0100 Subject: [PATCH] fix(attachments): Don't use currentSession for fetching attachments When switching pages in Collectives, `currentSession` might still be the session from the last page. The readonly view (`MarkdownContentEditor`) doesn't get a session, so the outdated session is used. Instead, always pass the session from `AttachmentResolver` to `setAttachmentList`. Fixes: nextcloud/collectives#1096 Fixes: nextcloud/collectives#1112 Signed-off-by: Jonas --- src/services/AttachmentResolver.js | 2 +- src/store/index.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/services/AttachmentResolver.js b/src/services/AttachmentResolver.js index 1f99caef392..4da5b474629 100644 --- a/src/services/AttachmentResolver.js +++ b/src/services/AttachmentResolver.js @@ -47,7 +47,7 @@ export default class AttachmentResolver { } async #updateAttachmentList() { - return setAttachmentList({ documentId: this.#documentId, shareToken: this.#shareToken }) + return setAttachmentList({ documentId: this.#documentId, session: this.#session, shareToken: this.#shareToken }) } /* diff --git a/src/store/index.js b/src/store/index.js index 5629fb82e29..d3f2eccd72f 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -96,11 +96,11 @@ export const textModule = { setHeadings({ commit }, value) { commit(SET_HEADINGS, value) }, - async setAttachmentList({ commit, state }, { documentId, shareToken }) { + async setAttachmentList({ commit }, { documentId, session, shareToken }) { const response = await axios.post(generateUrl('/apps/text/attachments'), { - documentId: state.currentSession?.documentId ?? documentId, - sessionId: state.currentSession?.id, - sessionToken: state.currentSession?.token, + documentId: session?.documentId ?? documentId, + sessionId: session?.id, + sessionToken: session?.token, shareToken, })