major improvements
This commit is contained in:
@@ -1649,6 +1649,58 @@ export function deleteBuildProfileForUser(userId: number, name: string): boolean
|
||||
return ((result as any)?.changes || 0) > 0;
|
||||
}
|
||||
|
||||
export interface SharedUiSettingsRecord {
|
||||
scope: string;
|
||||
settingsJson: string;
|
||||
updatedByUserId: number | null;
|
||||
updatedAt: number;
|
||||
}
|
||||
|
||||
export function getSharedUiSettings(scope: string): SharedUiSettingsRecord | null {
|
||||
const row = db
|
||||
.query<any>(
|
||||
`SELECT scope, settings_json, updated_by_user_id, updated_at
|
||||
FROM shared_ui_settings
|
||||
WHERE scope = ?`,
|
||||
)
|
||||
.get(scope);
|
||||
|
||||
if (!row) return null;
|
||||
return {
|
||||
scope: String(row.scope || ""),
|
||||
settingsJson: String(row.settings_json || "{}"),
|
||||
updatedByUserId: row.updated_by_user_id == null ? null : Number(row.updated_by_user_id),
|
||||
updatedAt: Number(row.updated_at) || 0,
|
||||
};
|
||||
}
|
||||
|
||||
export function saveSharedUiSettings(
|
||||
scope: string,
|
||||
settingsJson: string,
|
||||
updatedByUserId: number,
|
||||
): SharedUiSettingsRecord {
|
||||
const now = Date.now();
|
||||
db.run(
|
||||
`INSERT INTO shared_ui_settings (scope, settings_json, updated_by_user_id, updated_at)
|
||||
VALUES (?, ?, ?, ?)
|
||||
ON CONFLICT(scope) DO UPDATE SET
|
||||
settings_json = excluded.settings_json,
|
||||
updated_by_user_id = excluded.updated_by_user_id,
|
||||
updated_at = excluded.updated_at`,
|
||||
scope,
|
||||
settingsJson,
|
||||
updatedByUserId,
|
||||
now,
|
||||
);
|
||||
|
||||
return {
|
||||
scope,
|
||||
settingsJson,
|
||||
updatedByUserId,
|
||||
updatedAt: now,
|
||||
};
|
||||
}
|
||||
|
||||
export interface SavedScriptRecord {
|
||||
id: string;
|
||||
userId: number;
|
||||
|
||||
@@ -329,6 +329,15 @@ db.run(`
|
||||
`);
|
||||
db.run(`CREATE INDEX IF NOT EXISTS idx_build_profiles_user_updated ON build_profiles(user_id, updated_at DESC);`);
|
||||
|
||||
db.run(`
|
||||
CREATE TABLE IF NOT EXISTS shared_ui_settings (
|
||||
scope TEXT PRIMARY KEY,
|
||||
settings_json TEXT NOT NULL,
|
||||
updated_by_user_id INTEGER,
|
||||
updated_at INTEGER NOT NULL
|
||||
);
|
||||
`);
|
||||
|
||||
db.run(`
|
||||
CREATE TABLE IF NOT EXISTS saved_scripts (
|
||||
id TEXT PRIMARY KEY,
|
||||
|
||||
Reference in New Issue
Block a user