Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/photos.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Chemineau <louis@chmn.me>2022-08-24 14:25:23 +0300
committernextcloud-command <nextcloud-command@users.noreply.github.com>2022-09-16 10:44:28 +0300
commit35af1060979b67942a11ef1f2d2d73050c74af9e (patch)
tree6220db5001b83fbc2a64478f423b8dccfff26f07 /src/store/files.js
parentac8c298b2e01adc736ae29ab14cbc3cb52525fa7 (diff)
Add collaborators management views
Signed-off-by: Louis Chemineau <louis@chmn.me> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
Diffstat (limited to 'src/store/files.js')
-rw-r--r--src/store/files.js57
1 files changed, 39 insertions, 18 deletions
diff --git a/src/store/files.js b/src/store/files.js
index 278516fb..f0681860 100644
--- a/src/store/files.js
+++ b/src/store/files.js
@@ -20,10 +20,12 @@
*
*/
import Vue from 'vue'
+
import moment from '@nextcloud/moment'
+import { showError } from '@nextcloud/dialogs'
-import { deleteFile, favoriteFile, downloadFiles } from '../services/FileActions.js'
import logger from '../services/logger.js'
+import client from '../services/DavClient.js'
import Semaphore from '../utils/semaphoreWithPriority.js'
const state = {
@@ -108,10 +110,10 @@ const mutations = {
* @param {object} state the store mutations
* @param {object} params -
* @param {number} params.fileId - The id of the file
- * @param {boolean} params.favoriteState - The ew state of the favorite property
+ * @param {0|1} params.favoriteState - The ew state of the favorite property
*/
favoriteFile(state, { fileId, favoriteState }) {
- Vue.set(state.files[fileId], 'favorite', favoriteState ? 1 : 0)
+ Vue.set(state.files[fileId], 'favorite', favoriteState)
},
}
@@ -174,12 +176,16 @@ const actions = {
const promises = fileIds
.map(async (fileId) => {
+ const file = files[fileId]
const symbol = await semaphore.acquire()
+
try {
- await deleteFile(files[fileId].filename)
+ await client.deleteFile(file.filename)
} catch (error) {
+ logger.error(t('photos', 'Failed to delete {fileId}.', { fileId }), error)
+ showError(t('photos', 'Failed to delete {fileName}.', { fileName: file.basename }))
console.error(error)
- context.dispatch('appendFiles', [files[fileId]])
+ context.dispatch('appendFiles', [file])
} finally {
semaphore.release(symbol)
}
@@ -194,31 +200,46 @@ const actions = {
* @param {object} context the store mutations
* @param {object} params -
* @param {number[]} params.fileIds - The ids of the files
- * @param {boolean} params.favoriteState - The favorite state to set
+ * @param {0|1} params.favoriteState - The favorite state to set
*/
toggleFavoriteForFiles(context, { fileIds, favoriteState }) {
const semaphore = new Semaphore(5)
const promises = fileIds
.map(async (fileId) => {
+ const file = context.state.files[fileId]
const symbole = await semaphore.acquire()
- await favoriteFile(state.files[fileId].filename, favoriteState)
- context.commit('favoriteFile', { fileId, favoriteState })
+
+ try {
+ context.commit('favoriteFile', { fileId, favoriteState })
+ await client.customRequest(
+ file.filename,
+ {
+ method: 'PROPPATCH',
+ data: `<?xml version="1.0"?>
+ <d:propertyupdate xmlns:d="DAV:"
+ xmlns:oc="http://owncloud.org/ns"
+ xmlns:nc="http://nextcloud.org/ns"
+ xmlns:ocs="http://open-collaboration-services.org/ns">
+ <d:set>
+ <d:prop>
+ <oc:favorite>${favoriteState}</oc:favorite>
+ </d:prop>
+ </d:set>
+ </d:propertyupdate>`,
+ }
+ )
+ } catch (error) {
+ context.commit('favoriteFile', { fileId, favoriteState: favoriteState === 0 ? 1 : 0 })
+ logger.error(t('photos', 'Failed to set favorite state for {fileId}.', { fileId: file.fileid }), error)
+ showError(t('photos', 'Failed to set favorite state for {fileName}.', { fileName: file.basename }))
+ }
+
return semaphore.release(symbole)
})
return Promise.all(promises)
},
-
- /**
- * Download a list of files
- *
- * @param {object} context the store mutations
- * @param {number[]} fileIds - The ids of the files
- */
- downloadFiles(context, fileIds) {
- downloadFiles(fileIds.map(fileId => context.state.files[fileId].filename))
- },
}
export default { state, mutations, getters, actions }