From cc2329ec67686ad6f54bc79e0a92d164cfd75386 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Sun, 14 Jul 2024 16:26:07 -0400 Subject: [PATCH] fix(ags): close clipboard when copying old item --- modules/ags/config/eslint.config.js | 2 +- modules/ags/config/ts/clipboard/main.ts | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/modules/ags/config/eslint.config.js b/modules/ags/config/eslint.config.js index 923f2b6d..e5f29a98 100644 --- a/modules/ags/config/eslint.config.js +++ b/modules/ags/config/eslint.config.js @@ -105,6 +105,7 @@ export default tseslint.config( selector: [ 'import', 'objectLiteralProperty', + 'objectLiteralMethod', 'typeProperty', ], format: null, @@ -124,7 +125,6 @@ export default tseslint.config( 'classProperty', 'typeProperty', 'classMethod', - 'objectLiteralMethod', 'typeMethod', 'accessor', 'enumMember', diff --git a/modules/ags/config/ts/clipboard/main.ts b/modules/ags/config/ts/clipboard/main.ts index 72a7f46a..8a0f4728 100644 --- a/modules/ags/config/ts/clipboard/main.ts +++ b/modules/ags/config/ts/clipboard/main.ts @@ -23,7 +23,10 @@ export default () => { class_name: 'item', name: key.toString(), - on_primary_click_release: () => Clipboard.copyOldItem(key), + on_primary_click_release: () => { + Clipboard.copyOldItem(key); + App.closeWindow('win-clipboard'); + }, child: Box({ children: [ @@ -52,19 +55,22 @@ export default () => { class_name: 'clipboard', transition: 'slide top', - on_select: (r) => Clipboard.copyOldItem(getKey(r)), + on_select: (r) => { + Clipboard.copyOldItem(getKey(r)); + App.closeWindow('win-clipboard'); + }, init_rows: (list) => { Clipboard.getHistory(); - const connectId = Clipboard.connect('history-searched', () => { + const CONNECT_ID = Clipboard.connect('history-searched', () => { list.get_children().forEach((row) => { row.destroy(); }); Clipboard.clips.forEach((clip, key) => { makeItem(list, key, clip.clip, clip.isImage); }); - Clipboard.disconnect(connectId); + Clipboard.disconnect(CONNECT_ID); }); }, @@ -81,10 +87,10 @@ export default () => { fzfResults = fzf.find(text); list.set_sort_func((a, b) => { - const row1 = fzfResults.find((f) => f.item[0] === getKey(a))?.score ?? 0; - const row2 = fzfResults.find((f) => f.item[0] === getKey(b))?.score ?? 0; + const ROW_1 = fzfResults.find((f) => f.item[0] === getKey(a))?.score ?? 0; + const ROW_2 = fzfResults.find((f) => f.item[0] === getKey(b))?.score ?? 0; - return row2 - row1; + return ROW_2 - ROW_1; }); } },