store settings in localstorage
This commit is contained in:
@@ -7,20 +7,34 @@ import { decryptNotes, encryptionKey } from '@/composables/useEncryption'
|
||||
import { defaultNotes } from '@/utils/defaultNotes'
|
||||
import { mdToHtml } from '@/utils/markdown'
|
||||
import { getAllMatches } from '@/utils/helpers'
|
||||
import { preferredNotesSource } from '@/composables/useSettings'
|
||||
|
||||
export const notesSources = computed(() => ({
|
||||
local: true,
|
||||
firebase: initialized.value && user.value
|
||||
}))
|
||||
|
||||
type notesSourceValues = keyof typeof notesSources.value | null
|
||||
export const availableNotesSources = computed(() =>
|
||||
Object.entries(notesSources.value)
|
||||
.filter(([, enabled]) => enabled)
|
||||
.map(([source]) => source)
|
||||
)
|
||||
|
||||
export type notesSourceValues = keyof typeof notesSources.value | null
|
||||
|
||||
export const activeNotesSource = ref<notesSourceValues>(null)
|
||||
|
||||
watchEffect(() => {
|
||||
const getSource = (): notesSourceValues => {
|
||||
if (!initialized.value) return null
|
||||
return user.value ? 'firebase' : 'local'
|
||||
if (
|
||||
preferredNotesSource.value &&
|
||||
availableNotesSources.value.includes(preferredNotesSource.value)
|
||||
) {
|
||||
return preferredNotesSource.value
|
||||
} else {
|
||||
return user.value ? 'firebase' : 'local'
|
||||
}
|
||||
}
|
||||
activeNotesSource.value = getSource()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user