diff options
author | Julien Veyssier <eneiluj@posteo.net> | 2021-12-21 16:29:01 +0300 |
---|---|---|
committer | Julien Veyssier <eneiluj@posteo.net> | 2022-01-03 12:27:37 +0300 |
commit | 81aebeec9b593e598009b797a27550dd295c848a (patch) | |
tree | a71921bd57e5f6798741794383da4f4279bf80be /src/nodes | |
parent | 32c0a37669f7d0cc9ee23d891c1432e74f583de4 (diff) |
use Vuex to store current session and get it in the ImageView component
rename some variables
use session auth instead of NC auth to serve images
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
Diffstat (limited to 'src/nodes')
-rw-r--r-- | src/nodes/ImageView.vue | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/nodes/ImageView.vue b/src/nodes/ImageView.vue index ce62fc7a1..cf0dd521e 100644 --- a/src/nodes/ImageView.vue +++ b/src/nodes/ImageView.vue @@ -61,6 +61,7 @@ import path from 'path' import { generateUrl, generateRemoteUrl } from '@nextcloud/router' import { getCurrentUser } from '@nextcloud/auth' +import store from './../mixins/store' const imageMimes = [ 'image/png', @@ -93,6 +94,9 @@ const getQueryVariable = (src, variable) => { export default { name: 'ImageView', + mixins: [ + store, + ], props: ['node', 'options', 'updateAttrs', 'view'], // eslint-disable-line data() { return { @@ -102,6 +106,9 @@ export default { } }, computed: { + currentSession() { + return this.$store.state.currentSession + }, davUrl() { if (getCurrentUser()) { const uid = getCurrentUser().uid @@ -118,20 +125,26 @@ export default { }, imageUrl() { if (this.src.startsWith('text://')) { + const documentId = this.currentSession?.documentId + const sessionId = this.currentSession?.id + const sessionToken = this.currentSession?.token const imageFileName = getQueryVariable(this.src, 'imageFileName') - const textFileId = getQueryVariable(this.src, 'textFileId') if (getCurrentUser()) { - return generateUrl('/apps/text/image?textFileId={textFileId}&imageFileName={imageFileName}', + return generateUrl('/apps/text/image?documentId={documentId}&sessionId={sessionId}&sessionToken={sessionToken}&imageFileName={imageFileName}', { - textFileId, + documentId, + sessionId, + sessionToken, imageFileName, }) } else { - return generateUrl('/apps/text/public/image?textFileId={textFileId}&imageFileName={imageFileName}&shareToken={token}', + return generateUrl('/apps/text/image?documentId={documentId}&sessionId={sessionId}&sessionToken={sessionToken}&imageFileName={imageFileName}&shareToken={shareToken}', { - textFileId, + documentId, + sessionId, + sessionToken, imageFileName, - token: this.token, + shareToken: this.token, }) } } |