Skip to content

Commit

Permalink
fix: clone variables instead instead of passing by reference
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroAkbal committed Oct 28, 2023
1 parent 18ea774 commit f86696a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
5 changes: 3 additions & 2 deletions composables/useBooruList.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { booruTypeList, completeBooruList } from 'assets/lib/rule-34-shared-resources/src/util/BooruUtils'
import { useStorage } from '@vueuse/core'
import type { Domain } from 'assets/js/domain'
import { cloneDeep } from 'lodash-es'

const defaultBooruList: Domain[] = [
{
Expand Down Expand Up @@ -83,7 +84,7 @@ const defaultBooruList: Domain[] = [
}
]

const userBooruList = useStorage('user-booruList', defaultBooruList, localStorage, {
const userBooruList = useStorage('user-booruList', cloneDeep(defaultBooruList), localStorage, {
writeDefaults: false
})

Expand All @@ -92,7 +93,7 @@ export function useBooruList() {
booruList: userBooruList,

resetBooruList() {
userBooruList.value = defaultBooruList
userBooruList.value = cloneDeep(defaultBooruList)
}
}
}
5 changes: 3 additions & 2 deletions composables/useTagCollections.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useStorage, useToggle } from '@vueuse/core'
import TagCollection from 'assets/js/tagCollection.dto'
import { cloneDeep } from 'lodash-es'

const defaultTagCollections: TagCollection[] = [
{
Expand Down Expand Up @@ -47,7 +48,7 @@ const defaultTagCollections: TagCollection[] = [
}
]

const tagCollections = useStorage('user-tagCollections', defaultTagCollections, localStorage, {
const tagCollections = useStorage('user-tagCollections', cloneDeep(defaultTagCollections), localStorage, {
writeDefaults: false
})

Expand All @@ -61,7 +62,7 @@ export function useTagCollections() {
tagCollections,

resetTagCollections() {
tagCollections.value = defaultTagCollections
tagCollections.value = cloneDeep(defaultTagCollections)
}
}
}
2 changes: 0 additions & 2 deletions pages/premium/tag-collections.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ function deleteItem() {
useSeoMeta({
title: 'Tag collections'
})
definePageMeta({ middleware: 'auth' })
</script>

<template>
Expand Down

0 comments on commit f86696a

Please sign in to comment.