From 128891f53ecb2f78c5eb059495114a66f25a58de Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Thu, 25 Jul 2024 13:40:04 +0100 Subject: fix(gui): do not hardcode db path (#2309) * feat(gui/backend): add cli_settings tauri command * chore(gui/backend): overdue cargo fmt * fix(gui): use configured db path, not hardcoded --- ui/src/state/models.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'ui/src/state/models.ts') diff --git a/ui/src/state/models.ts b/ui/src/state/models.ts index 4ca79006..891f7a55 100644 --- a/ui/src/state/models.ts +++ b/ui/src/state/models.ts @@ -1,3 +1,4 @@ +import { invoke } from "@tauri-apps/api/core"; import Database from "@tauri-apps/plugin-sql"; export class User { @@ -122,9 +123,8 @@ interface Sync { export async function inspectCommandHistory( h: ShellHistory, ): Promise { - const db = await Database.load( - "sqlite:/Users/ellie/.local/share/atuin/history.db", - ); + const settings: Settings = await invoke("cli_settings"); + const db = await Database.load("sqlite:" + settings.db_path); let other: any[] = await db.select( "select * from history where command=?1 order by timestamp desc", @@ -151,9 +151,8 @@ export async function inspectCommandHistory( export async function inspectDirectoryHistory( h: ShellHistory, ): Promise { - const db = await Database.load( - "sqlite:/Users/ellie/.local/share/atuin/history.db", - ); + const settings: Settings = await invoke("cli_settings"); + const db = await Database.load("sqlite:" + settings.db_path); let other: any[] = await db.select( "select * from history where cwd=?1 order by timestamp desc", -- cgit v1.3.1