aboutsummaryrefslogtreecommitdiffstats
path: root/apps/comments/src/store/deletedCommentLimbo.js
blob: 3e511addebb448f6715fddafb0454472f6a584b8 (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
/**
 * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

import { defineStore } from 'pinia'

export const useDeletedCommentLimbo = defineStore('deletedCommentLimbo', {
	state: () => ({
		idsInLimbo: [],
	}),
	actions: {
		addId(id) {
			this.idsInLimbo.push(id)
		},

		removeId(id) {
			const index = this.idsInLimbo.indexOf(id)
			if (index > -1) {
				this.idsInLimbo.splice(index, 1)
			}
		},

		checkForId(id) {
			this.idsInLimbo.includes(id)
		},
	},
})