diff options
author | Vincent Petry <vincent@nextcloud.com> | 2021-04-28 18:02:14 +0200 |
---|---|---|
committer | Vincent Petry <vincent@nextcloud.com> | 2021-04-29 09:47:21 +0200 |
commit | b9632cf7a380e5d86391b780bcfb89f11f8ff51e (patch) | |
tree | 3aa19901f48a7469ffc732b707c994ceda2dbaf8 /src/store | |
parent | 0bb284b5eeaf72ccabdbf9a9377d3e7d283b8747 (diff) |
Decuple fileUpload service from the global store
Moved the logic of "processFiles" into the existing "initialiseUpload"
action of the fileUploadStore
Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Diffstat (limited to 'src/store')
-rw-r--r-- | src/store/fileUploadStore.js | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/store/fileUploadStore.js b/src/store/fileUploadStore.js index ad182f3a0..315419598 100644 --- a/src/store/fileUploadStore.js +++ b/src/store/fileUploadStore.js @@ -24,7 +24,8 @@ import Vue from 'vue' import client from '../services/DavClient' import { showError } from '@nextcloud/dialogs' import fromStateOr from './helper' -import { findUniquePath } from '../utils/fileUpload' +import { findUniquePath, getFileExtension } from '../utils/fileUpload' +import moment from '@nextcloud/moment' import createTemporaryMessage from '../utils/temporaryMessage' import { EventBus } from '../services/EventBus' import { shareFile } from '../services/filesSharingServices' @@ -186,7 +187,23 @@ const mutations = { const actions = { - initialiseUpload({ commit, dispatch }, { uploadId, token, files }) { + /** + * Initialises uploads and shares files to a conversation + * + * @param {object} files the files to be processed + * @param {string} token the conversation's token where to share the files + * @param {number} uploadId a unique id for the upload operation indexing + * @param {bool} rename whether to rename the files (usually after pasting) + */ + initialiseUpload({ commit, dispatch }, { uploadId, token, files, rename = false }) { + if (rename) { + files.forEach(file => { + // note: can't overwrite the original read-only name attribute + file.newName = moment(file.lastModified || file.lastModifiedDate).format('YYYYMMDD_HHmmss') + + getFileExtension(file.name) + }) + } + // Set last upload id commit('setCurrentUploadId', uploadId) |