mirror of
https://github.com/directus/directus.git
synced 2026-01-23 13:37:58 -05:00
Prevent duplicate user presets
This commit is contained in:
@@ -30,6 +30,7 @@ export function usePreset(collection: Ref<string>, bookmark: Ref<number | null>
|
||||
localPreset.value = {
|
||||
...localPreset.value,
|
||||
id: updatedValues.id,
|
||||
user: updatedValues.user,
|
||||
};
|
||||
busy.value = false;
|
||||
return updatedValues;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Preset } from '@/types';
|
||||
import { useUserStore } from '@/stores/';
|
||||
import api from '@/api';
|
||||
import { nanoid } from 'nanoid';
|
||||
import { merge } from 'lodash';
|
||||
import { merge, cloneDeep } from 'lodash';
|
||||
|
||||
const defaultPreset: Omit<Preset, 'collection'> = {
|
||||
bookmark: null,
|
||||
@@ -246,7 +246,7 @@ export const usePresetsStore = createStore({
|
||||
const { id: userID } = userStore.state.currentUser;
|
||||
|
||||
// Clone the preset to make sure the future deletes don't affect the original object
|
||||
preset = { ...preset };
|
||||
preset = cloneDeep(preset);
|
||||
|
||||
if (preset.id === undefined || preset.id === null) {
|
||||
return await this.create({
|
||||
|
||||
Reference in New Issue
Block a user