diff options
author | Marco Ambrosini <marcoambrosini@pm.me> | 2022-06-23 16:58:52 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-08-31 09:15:38 +0300 |
commit | b32a4b72b9b7583bcd1b0753faa50b66853d66b8 (patch) | |
tree | 89c43f60f2f13b28cc41453367ae735d11c8b2fb /src | |
parent | 01f3cea5ffd26b8e6b815ea8059424687f6a046e (diff) |
Open text document
Signed-off-by: Marco Ambrosini <marcoambrosini@pm.me>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/NewMessageForm/NewMessageForm.vue | 6 | ||||
-rw-r--r-- | src/store/messagesStore.js | 12 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/components/NewMessageForm/NewMessageForm.vue b/src/components/NewMessageForm/NewMessageForm.vue index 3efca3294..d97dcfb11 100644 --- a/src/components/NewMessageForm/NewMessageForm.vue +++ b/src/components/NewMessageForm/NewMessageForm.vue @@ -630,7 +630,11 @@ export default { async handleCreateTextFile() { const filePath = this.textFileTitle + '.md' await createTextFile(filePath) - await shareFile(filePath, this.token) + const response = await shareFile(filePath, this.token) + // TODO: before getting the link from the system message we need + // to wait till the message itself is received + const link = this.$store.getters.getSharedFileLink(this.token, response.data.ocs.data.file_source) + window.open(link, '_self') this.dismissTextFileCreation() }, diff --git a/src/store/messagesStore.js b/src/store/messagesStore.js index b19b00545..4593fd389 100644 --- a/src/store/messagesStore.js +++ b/src/store/messagesStore.js @@ -209,6 +209,18 @@ const getters = { hasReactions: (state) => (token, messageId) => { return Object.keys(state.messages[token][messageId].reactions).length !== 0 }, + + getSharedFileLink: (state) => (token, fileId) => { + // Reverse the messages array, the message containing the file we want + // is going to be one of the last ones + const reversedMessages = Object.values(state.messages[token]).reverse() + for (const message of reversedMessages) { + if (message.messageParameters?.file?.id === fileId) { + return message.messageParameters.file.link + } + } + return undefined + }, } const mutations = { |