mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-05 22:02:39 +02:00
Add Screenshot Assist to stored shortcuts, default to Shift+Space, and migrate legacy autocomplete.
This commit is contained in:
parent
1c7362d9c6
commit
df952ffa28
1 changed files with 16 additions and 10 deletions
|
|
@ -1,11 +1,13 @@
|
||||||
export interface ShortcutConfig {
|
export interface ShortcutConfig {
|
||||||
generalAssist: string;
|
generalAssist: string;
|
||||||
quickAsk: string;
|
quickAsk: string;
|
||||||
|
screenshotAssist: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULTS: ShortcutConfig = {
|
const DEFAULTS: ShortcutConfig = {
|
||||||
generalAssist: 'CommandOrControl+Shift+S',
|
generalAssist: 'CommandOrControl+Shift+S',
|
||||||
quickAsk: 'CommandOrControl+Alt+S',
|
quickAsk: 'CommandOrControl+Alt+S',
|
||||||
|
screenshotAssist: 'CommandOrControl+Shift+Space',
|
||||||
};
|
};
|
||||||
|
|
||||||
const STORE_KEY = 'shortcuts';
|
const STORE_KEY = 'shortcuts';
|
||||||
|
|
@ -23,21 +25,25 @@ async function getStore() {
|
||||||
return store;
|
return store;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** One-time fix if both shortcuts match the mistaken Alt+Shift pair. */
|
|
||||||
function wasRegressionAltPair(rest: Record<string, string>): boolean {
|
|
||||||
return rest.generalAssist === 'Alt+Shift+G' && rest.quickAsk === 'Alt+Shift+Q';
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getShortcuts(): Promise<ShortcutConfig> {
|
export async function getShortcuts(): Promise<ShortcutConfig> {
|
||||||
const s = await getStore();
|
const s = await getStore();
|
||||||
const raw = (s.get(STORE_KEY) as Record<string, string> | undefined) ?? {};
|
const raw = (s.get(STORE_KEY) as Record<string, string> | undefined) ?? {};
|
||||||
|
const legacyAutocomplete = raw.autocomplete;
|
||||||
const { autocomplete: _drop, ...rest } = raw;
|
const { autocomplete: _drop, ...rest } = raw;
|
||||||
if (wasRegressionAltPair(rest)) {
|
let merged: ShortcutConfig = { ...DEFAULTS, ...rest };
|
||||||
const fixed = { ...DEFAULTS };
|
if (
|
||||||
s.set(STORE_KEY, { ...fixed });
|
typeof legacyAutocomplete === 'string' &&
|
||||||
return fixed;
|
legacyAutocomplete.length > 0 &&
|
||||||
|
!('screenshotAssist' in raw)
|
||||||
|
) {
|
||||||
|
merged = { ...merged, screenshotAssist: legacyAutocomplete };
|
||||||
|
s.set(STORE_KEY, {
|
||||||
|
generalAssist: merged.generalAssist,
|
||||||
|
quickAsk: merged.quickAsk,
|
||||||
|
screenshotAssist: merged.screenshotAssist,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return { ...DEFAULTS, ...rest };
|
return merged;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function setShortcuts(config: Partial<ShortcutConfig>): Promise<ShortcutConfig> {
|
export async function setShortcuts(config: Partial<ShortcutConfig>): Promise<ShortcutConfig> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue