mirror of
https://github.com/haexhub/haex-hub.git
synced 2025-12-17 06:30:50 +01:00
fix submit handler
This commit is contained in:
@ -128,7 +128,7 @@ const addGroupAsync = async (group: Partial<InsertHaexPasswordsGroups>) => {
|
||||
name: group.name,
|
||||
order: group.order,
|
||||
}
|
||||
await currentVault.drizzle.insert(haexPasswordsGroups).values(newGroup)
|
||||
await currentVault.drizzle?.insert(haexPasswordsGroups).values(newGroup)
|
||||
await syncGroupItemsAsync()
|
||||
return newGroup
|
||||
}
|
||||
@ -138,7 +138,7 @@ const readGroupAsync = async (groupId: string) => {
|
||||
|
||||
return (
|
||||
await currentVault.drizzle
|
||||
.select()
|
||||
?.select()
|
||||
.from(haexPasswordsGroups)
|
||||
.where(eq(haexPasswordsGroups.id, groupId))
|
||||
).at(0)
|
||||
@ -166,12 +166,12 @@ const readGroupItemsAsync = async (
|
||||
|
||||
if (groupId) {
|
||||
return currentVault.drizzle
|
||||
.select()
|
||||
?.select()
|
||||
.from(haexPasswordsGroupItems)
|
||||
.where(eq(haexPasswordsGroupItems.groupId, groupId))
|
||||
} else {
|
||||
return currentVault.drizzle
|
||||
.select()
|
||||
?.select()
|
||||
.from(haexPasswordsGroupItems)
|
||||
.where(isNull(haexPasswordsGroupItems.groupId))
|
||||
}
|
||||
@ -198,7 +198,7 @@ const getByParentIdAsync = async (
|
||||
console.log('getByParentIdAsync', parentId)
|
||||
if (parentId) {
|
||||
const groups = await currentVault.drizzle
|
||||
.select()
|
||||
?.select()
|
||||
.from(haexPasswordsGroups)
|
||||
.where(eq(haexPasswordsGroups.parentId, parentId))
|
||||
.orderBy(sql`${haexPasswordsGroups.order} nulls last`)
|
||||
@ -206,7 +206,7 @@ const getByParentIdAsync = async (
|
||||
return groups
|
||||
} else {
|
||||
const groups = await currentVault.drizzle
|
||||
.select()
|
||||
?.select()
|
||||
.from(haexPasswordsGroups)
|
||||
.where(isNull(haexPasswordsGroups.parentId))
|
||||
.orderBy(sql`${haexPasswordsGroups.order} nulls last`)
|
||||
@ -238,10 +238,20 @@ const updateAsync = async (group: InsertHaexPasswordsGroups) => {
|
||||
const { currentVault } = storeToRefs(useVaultStore())
|
||||
if (!group.id) return
|
||||
|
||||
const newGroup: InsertHaexPasswordsGroups = {
|
||||
id: group.id,
|
||||
color: group.color,
|
||||
description: group.description,
|
||||
icon: group.icon,
|
||||
name: group.name,
|
||||
order: group.order,
|
||||
parentId: group.parentId,
|
||||
}
|
||||
|
||||
return currentVault.value.drizzle
|
||||
.update(haexPasswordsGroups)
|
||||
.set(group)
|
||||
.where(eq(haexPasswordsGroups.id, group.id))
|
||||
.set(newGroup)
|
||||
.where(eq(haexPasswordsGroups.id, newGroup.id))
|
||||
}
|
||||
|
||||
const navigateToGroupItemsAsync = (groupId: string) => {
|
||||
|
||||
@ -15,7 +15,7 @@ const getAsync = async (itemId: string | null) => {
|
||||
const { currentVault } = useVaultStore()
|
||||
|
||||
const history = await currentVault.drizzle
|
||||
.select()
|
||||
?.select()
|
||||
.from(haexPasswordsItemHistory)
|
||||
.where(eq(haexPasswordsItemHistory.itemId, itemId))
|
||||
|
||||
|
||||
@ -121,12 +121,14 @@ export const useVaultSettingsStore = defineStore('vaultSettingsStore', () => {
|
||||
const readDeviceNameAsync = async (id: string) => {
|
||||
const { currentVault } = useVaultStore()
|
||||
|
||||
const deviceName = await currentVault.drizzle.query.haexSettings.findFirst({
|
||||
where: and(
|
||||
eq(schema.haexSettings.type, VaultSettingsTypeEnum.deviceName),
|
||||
eq(schema.haexSettings.key, id),
|
||||
),
|
||||
})
|
||||
const deviceName = await currentVault.drizzle?.query.haexSettings.findFirst(
|
||||
{
|
||||
where: and(
|
||||
eq(schema.haexSettings.type, VaultSettingsTypeEnum.deviceName),
|
||||
eq(schema.haexSettings.key, id),
|
||||
),
|
||||
},
|
||||
)
|
||||
console.log('readDeviceNameAsync', deviceName)
|
||||
return deviceName
|
||||
}
|
||||
@ -146,7 +148,7 @@ export const useVaultSettingsStore = defineStore('vaultSettingsStore', () => {
|
||||
return
|
||||
}
|
||||
|
||||
return currentVault.drizzle.insert(schema.haexSettings).values({
|
||||
return currentVault.drizzle?.insert(schema.haexSettings).values({
|
||||
id: crypto.randomUUID(),
|
||||
type: VaultSettingsTypeEnum.deviceName,
|
||||
key: deviceId,
|
||||
@ -167,7 +169,7 @@ export const useVaultSettingsStore = defineStore('vaultSettingsStore', () => {
|
||||
if (!isNameOk.success) return
|
||||
|
||||
return currentVault.drizzle
|
||||
.update(schema.haexSettings)
|
||||
?.update(schema.haexSettings)
|
||||
.set({
|
||||
value: deviceName,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user