Feature: fix extension delete (#96)

* chore: improve database and extension handling

- Remove debug console log in extension uninstall
- Add ON DELETE CASCADE to extension-related foreign keys
- Enable foreign key constraints in database connection
- Update database file extensions from .db to .sqlite
- Modify command value generation for better identification

* fix: add small delay to onboarding page navigation

Without delay the page switch won't be triggered when window first loads
This commit is contained in:
Huakun Shen 2025-02-07 04:43:24 -05:00 committed by GitHub
parent 27fdff03d9
commit 839bad6751
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 10 additions and 18 deletions

View File

@ -32,8 +32,7 @@
QuickLinks, QuickLinks,
SystemCmds SystemCmds
} from "@kksh/ui/main" } from "@kksh/ui/main"
import type { CmdValue } from "@kksh/ui/types" import { cn } from "@kksh/ui/utils"
import { cn, commandScore } from "@kksh/ui/utils"
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow" import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow"
import { getCurrentWindow, Window } from "@tauri-apps/api/window" import { getCurrentWindow, Window } from "@tauri-apps/api/window"
import { platform } from "@tauri-apps/plugin-os" import { platform } from "@tauri-apps/plugin-os"
@ -74,7 +73,9 @@
// to keep track of the loading status // to keep track of the loading status
if (loaded) { if (loaded) {
if (!appConfig.get().onBoarded) { if (!appConfig.get().onBoarded) {
goto(i18n.resolveRoute("/app/help/onboarding")) setTimeout(() => {
goto(i18n.resolveRoute("/app/help/onboarding"))
}, 300)
} }
} }
}) })
@ -93,15 +94,6 @@
} }
}} }}
/> />
<!-- <div>appsFiltered: {$appsFiltered.length}</div> -->
<!-- <div>appsLoader: {$appsLoader.length}</div> -->
<!-- filter={(value, search, keywords) => {
return commandScore(
value.startsWith("{") ? (JSON.parse(value) as CmdValue).cmdName : value,
search,
keywords
)
}} -->
<Command.Root <Command.Root
class={cn("h-screen rounded-lg border shadow-md")} class={cn("h-screen rounded-lg border shadow-md")}
bind:value={$appState.highlightedCmd} bind:value={$appState.highlightedCmd}

View File

@ -15,7 +15,6 @@
uninstalling = true uninstalling = true
const extContainerPath = get(appConfig).extensionsInstallDir const extContainerPath = get(appConfig).extensionsInstallDir
const isDev = extContainerPath && extAPI.isExtPathInDev(extContainerPath, ext.extPath) const isDev = extContainerPath && extAPI.isExtPathInDev(extContainerPath, ext.extPath)
console.log("uninstall extension (isDev): ", isDev)
const uninstallFunc = isDev const uninstallFunc = isDev
? extensions.uninstallDevExtensionByIdentifier ? extensions.uninstallDevExtensionByIdentifier

View File

@ -28,7 +28,7 @@ CREATE TABLE IF NOT EXISTS commands (
) )
), ),
data JSON, data JSON,
FOREIGN KEY (ext_id) REFERENCES extensions (ext_id) FOREIGN KEY (ext_id) REFERENCES extensions (ext_id) ON DELETE CASCADE
); );
-- Extension Data table -- Extension Data table
@ -41,7 +41,7 @@ CREATE TABLE IF NOT EXISTS extension_data (
search_text TEXT, search_text TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (ext_id) REFERENCES extensions (ext_id) FOREIGN KEY (ext_id) REFERENCES extensions (ext_id) ON DELETE CASCADE
); );
-- Full-text search index for ext_data -- Full-text search index for ext_data

View File

@ -14,6 +14,7 @@ pub fn get_connection<P: AsRef<Path>>(
let conn = Connection::open(file_path)?; let conn = Connection::open(file_path)?;
if let Some(encryption_key) = encryption_key { if let Some(encryption_key) = encryption_key {
conn.pragma_update(None, "key", &encryption_key)?; conn.pragma_update(None, "key", &encryption_key)?;
conn.pragma_update(None, "foreign_keys", "ON")?;
} }
Ok(conn) Ok(conn)
} }

View File

@ -17,8 +17,8 @@ pub fn get_default_extensions_storage_dir<R: Runtime>(
pub fn get_kunkun_db_path<R: Runtime>(app: &AppHandle<R>) -> anyhow::Result<PathBuf> { pub fn get_kunkun_db_path<R: Runtime>(app: &AppHandle<R>) -> anyhow::Result<PathBuf> {
Ok(app.path().app_data_dir()?.join(if cfg!(debug_assertions) { Ok(app.path().app_data_dir()?.join(if cfg!(debug_assertions) {
"kk.dev.db" "kk.dev.sqlite"
} else { } else {
"kk.db" "kk.sqlite"
})) }))
} }

View File

@ -34,7 +34,7 @@
onSelect={() => { onSelect={() => {
onExtCmdSelect(ext, cmd, { isDev, hmr }) onExtCmdSelect(ext, cmd, { isDev, hmr })
}} }}
value={cmd.name} value={`${isDev ? "dev-ext" : "ext"}-${cmd.name}`}
> >
<!-- value={JSON.stringify({ <!-- value={JSON.stringify({
cmdName: cmd.name, cmdName: cmd.name,