Skip to content

Commit 600751b

Browse files
committed
fix: resolve lint safety errors in SQL and preferences persistence
1 parent 78d64e8 commit 600751b

4 files changed

Lines changed: 132 additions & 125 deletions

File tree

dist/main.js

Lines changed: 117 additions & 117 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/platform/integrations/anki/anki-sql.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ import {
3434

3535
let _sqlJs: SqlJsStatic | null = null;
3636
let _sqlJsPromise: Promise<SqlJsStatic> | null = null;
37+
const initSqlJsTyped = initSqlJs as unknown as (config: {
38+
wasmBinary: ArrayBuffer;
39+
}) => Promise<SqlJsStatic>;
3740

3841
/**
3942
* Lazily initialise sql.js. Uses the bundled sql.js package and embedded WASM
@@ -49,7 +52,7 @@ export async function getSqlJs(): Promise<SqlJsStatic> {
4952
: new Uint8Array(wasmBinary);
5053
const wasmBuffer = wasmArray.slice().buffer;
5154

52-
_sqlJs = await initSqlJs({ wasmBinary: wasmBuffer });
55+
_sqlJs = await initSqlJsTyped({ wasmBinary: wasmBuffer });
5356
return _sqlJs;
5457
})().catch((err) => {
5558
// Reset so the next call retries instead of returning a stale rejected promise

src/views/browser/card-browser-view.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,18 +388,20 @@ export class SproutCardBrowserView extends ItemView {
388388

389389
private _queuePersistBrowserPrefs() {
390390
if (this._browserPrefsSaveTimer !== null) return;
391-
this._browserPrefsSaveTimer = setTimeout(async () => {
391+
this._browserPrefsSaveTimer = setTimeout(() => {
392+
void (async () => {
392393
this._browserPrefsSaveTimer = null;
393394
try {
394-
const root = (await this.plugin.loadData()) || {};
395-
root[BROWSER_PREFS_ROOT_KEY] = {
395+
const root = (await this.plugin.loadData()) as Record<string, unknown> | null;
396+
const nextRoot: Record<string, unknown> = root ?? {};
397+
nextRoot[BROWSER_PREFS_ROOT_KEY] = {
396398
density: this._densityMode,
397399
cols: {
398400
comfortable: Array.from(this._comfortableCols),
399401
compact: Array.from(this._compactCols),
400402
},
401403
};
402-
await this.plugin.saveData(root);
404+
await this.plugin.saveData(nextRoot);
403405
// One-time cleanup: remove legacy localStorage keys
404406
try {
405407
window.localStorage.removeItem(BROWSER_DENSITY_STORAGE_KEY);
@@ -410,6 +412,7 @@ export class SproutCardBrowserView extends ItemView {
410412
this._saveDensityMode();
411413
this._saveColumnPrefs();
412414
}
415+
})();
413416
}, 300);
414417
}
415418

src/views/study-assistant/popup/assistant-popup.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,13 @@ export class SproutAssistantPopup {
312312
// Write to data.json asynchronously; fall back to localStorage on failure.
313313
void (async () => {
314314
try {
315-
const root = (await this.plugin.loadData()) || {};
316-
root[ASSISTANT_POPUP_PREFS_ROOT_KEY] = {
315+
const root = (await this.plugin.loadData()) as Record<string, unknown> | null;
316+
const nextRoot: Record<string, unknown> = root ?? {};
317+
nextRoot[ASSISTANT_POPUP_PREFS_ROOT_KEY] = {
317318
width: this._userResizedWidth,
318319
height: this._userResizedHeight,
319320
};
320-
await this.plugin.saveData(root);
321+
await this.plugin.saveData(nextRoot);
321322
// One-time cleanup: remove legacy localStorage key
322323
try { window.localStorage.removeItem(ASSISTANT_POPUP_SIZE_STORAGE_KEY); } catch { /* ignore */ }
323324
} catch {

0 commit comments

Comments
 (0)