allow for temporary presets (#4724)

This commit is contained in:
Nitwel
2021-03-29 16:20:09 +02:00
committed by GitHub
parent 07aff68532
commit 706dca1740
2 changed files with 3 additions and 2 deletions

View File

@@ -5,7 +5,7 @@ import { useCollection } from '@/composables/use-collection';
import { Filter, Preset } from '@/types/';
export function usePreset(collection: Ref<string>, bookmark: Ref<number | null> = ref(null)) {
export function usePreset(collection: Ref<string>, bookmark: Ref<number | null> = ref(null), temporary = false) {
const presetsStore = usePresetsStore();
const userStore = useUserStore();
@@ -29,6 +29,7 @@ export function usePreset(collection: Ref<string>, bookmark: Ref<number | null>
* @param preset The preset that should be saved
*/
const savePreset = async (preset?: Partial<Preset>) => {
if (temporary) return;
busy.value = true;
const updatedValues = await presetsStore.savePreset(preset ? preset : localPreset.value);

View File

@@ -70,7 +70,7 @@ export default defineComponent({
const { collection } = toRefs(props);
const { info: collectionInfo } = useCollection(collection);
const { layout, layoutOptions, layoutQuery, searchQuery } = usePreset(collection);
const { layout, layoutOptions, layoutQuery, searchQuery } = usePreset(collection, ref(null), true);
// This is a local copy of the layout. This means that we can sync it the layout without
// having use-preset auto-save the values