mirror of
https://github.com/haexhub/haex-hub.git
synced 2025-12-16 14:10:52 +01:00
fix update vault name
This commit is contained in:
@ -8,9 +8,9 @@
|
||||
<div class="p-2">{{ t('design') }}</div>
|
||||
<div><UiDropdownTheme @select="onSelectThemeAsync" /></div>
|
||||
|
||||
<div class="p-2">{{ t('vaultName') }}</div>
|
||||
<div class="p-2">{{ t('vaultName.label') }}</div>
|
||||
<div>
|
||||
<UiInput v-model="currentVaultName" :placeholder="t('vaultName')">
|
||||
<UiInput v-model="currentVaultName" :placeholder="t('vaultName.label')">
|
||||
<template #append>
|
||||
<UiTooltip :tooltip="t('save')">
|
||||
<UiButton class="btn-primary" @click="onSetVaultNameAsync">
|
||||
@ -38,27 +38,31 @@ const { currentVault, currentVaultName } = storeToRefs(useVaultStore())
|
||||
const { updateVaultNameAsync } = useVaultStore()
|
||||
|
||||
const onSelectLocaleAsync = async (locale: Locale) => {
|
||||
console.log('onSelectLocaleAsync', locale)
|
||||
const update = await currentVault.value?.drizzle
|
||||
await currentVault.value?.drizzle
|
||||
.update(haexSettings)
|
||||
.set({ key: 'locale', value: locale })
|
||||
.where(eq(haexSettings.key, 'locale'))
|
||||
await setLocale(locale)
|
||||
console.log('update locale', update)
|
||||
}
|
||||
|
||||
const { currentTheme } = storeToRefs(useUiStore())
|
||||
|
||||
const onSelectThemeAsync = async (theme: ITheme) => {
|
||||
const update = await currentVault.value?.drizzle
|
||||
await currentVault.value?.drizzle
|
||||
.update(haexSettings)
|
||||
.set({ key: 'theme', value: theme.name })
|
||||
.where(eq(haexSettings.key, 'theme'))
|
||||
currentTheme.value = theme
|
||||
}
|
||||
|
||||
const onSetVaultNameAsync = async (vaultName: string) => {
|
||||
updateVaultNameAsync(vaultName)
|
||||
const { add } = useSnackbar()
|
||||
const onSetVaultNameAsync = async () => {
|
||||
try {
|
||||
await updateVaultNameAsync(currentVaultName.value)
|
||||
add({ text: t('vaultName.update.success'), type: 'success' })
|
||||
} catch (error) {
|
||||
add({ text: t('vaultName.update.error'), type: 'error' })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -66,12 +70,19 @@ const onSetVaultNameAsync = async (vaultName: string) => {
|
||||
de:
|
||||
language: Sprache
|
||||
design: Design
|
||||
vaultName: Vaultname
|
||||
save: Änderung speichern
|
||||
|
||||
vaultName:
|
||||
label: Vaultname
|
||||
update:
|
||||
success: Vaultname erfolgreich aktualisiert
|
||||
error: Vaultname konnte nicht aktualisiert werden
|
||||
en:
|
||||
language: Language
|
||||
design: Design
|
||||
vaultName: Vault Name
|
||||
save: save changes
|
||||
vaultName:
|
||||
label: Vault Name
|
||||
update:
|
||||
success: Vault Name successfully updated
|
||||
error: Vault name could not be updated
|
||||
</i18n>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
|
||||
import * as schema from "@/../src-tauri/database/schemas/vault";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { hostname, platform, type, version } from "@tauri-apps/plugin-os";
|
||||
import { platform } from "@tauri-apps/plugin-os";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { drizzle, SqliteRemoteDatabase } from "drizzle-orm/sqlite-proxy";
|
||||
|
||||
@ -45,16 +45,9 @@ export const useVaultStore = defineStore("vaultStore", () => {
|
||||
|
||||
const openVaults = ref<IOpenVaults>({});
|
||||
|
||||
const currentVault = computed(() => openVaults.value?.[currentVaultId.value ?? ""]) //ref<IVault>();
|
||||
const currentVault = computed(() => openVaults.value?.[currentVaultId.value ?? ""])
|
||||
|
||||
/* watch(
|
||||
currentVaultId,
|
||||
() => {
|
||||
currentVault.value = openVaults.value?.[currentVaultId.value ?? ""];
|
||||
}
|
||||
); */
|
||||
|
||||
const hostKey = computedAsync(async () => "".concat(type(), version(), await hostname() ?? ""))
|
||||
|
||||
const openAsync = async ({ path = "", password }: { path: string; password: string }) => {
|
||||
try {
|
||||
@ -213,6 +206,7 @@ export const useVaultStore = defineStore("vaultStore", () => {
|
||||
}
|
||||
|
||||
const updateVaultNameAsync = async (newVaultName?: string | null) => {
|
||||
console.log("set new vaultName", newVaultName)
|
||||
return currentVault.value?.drizzle.update(schema.haexSettings).set({ value: newVaultName ?? defaultVaultName.value }).where(eq(schema.haexSettings.key, "vaultName"))
|
||||
}
|
||||
|
||||
@ -222,7 +216,6 @@ export const useVaultStore = defineStore("vaultStore", () => {
|
||||
currentVault,
|
||||
currentVaultId,
|
||||
currentVaultName,
|
||||
hostKey,
|
||||
openAsync,
|
||||
openVaults,
|
||||
read_only,
|
||||
|
||||
Reference in New Issue
Block a user