aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/src/store/dragging.ts
blob: 667c6fe67a7266c6d611d4f0d42ebc059249e7c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
 * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
import { defineStore } from 'pinia'
import Vue from 'vue'
import type { DragAndDropStore, FileSource } from '../types'

export const useDragAndDropStore = defineStore('dragging', {
	state: () => ({
		dragging: [],
	} as DragAndDropStore),

	actions: {
		/**
		 * Set the selection of fileIds
		 * @param selection
		 */
		set(selection = [] as FileSource[]) {
			Vue.set(this, 'dragging', selection)
		},

		/**
		 * Reset the selection
		 */
		reset() {
			Vue.set(this, 'dragging', [])
		},
	},
})