Edge-Drop is a clipboard shelf on the edge of your screen. Hover to open it. Drag files and images into any app, click to copy text and links. Free and open-source for Windows.
TypeScript clipboardclipboard-managerdesktop-appdrag-and-dropelectronopen-sourceproductivityproductivity-toolwindows
perf(store): add atomic batch deletion IPC to eliminate multi-item removal lag
Deepender25b40c290960ba
diff --git a/electron/main/ipc.ts b/electron/main/ipc.tsindex 6ce21f5..69bf3b0 100644--- a/electron/main/ipc.ts+++ b/electron/main/ipc.ts@@ -251,6 +251,18 @@ export function registerIpc(): void {return getStore().toDto()})+ handle('item:delete-batch', (ids) => {+ if (!ids || ids.length === 0) return getStore().toDto()+ const items = ids.map((id) => getStore().get(id)).filter(Boolean)+ getStore().deleteBatch(ids)+ if (items.some((item) => item && clipboardMatchesItem(item.data))) {+ clipboard.clear()+ }+ getWatcher().resyncSignature()+ pushState.items()+ return getStore().toDto()+ })+handle('item:clear', () => {getStore().clearUnpinned()// Clear the system clipboard unconditionally: the user wiped their history,diff --git a/electron/preload/index.ts b/electron/preload/index.tsindex 0b00fff..33a70e0 100644--- a/electron/preload/index.ts+++ b/electron/preload/index.ts@@ -141,6 +141,7 @@ const api = {loadState: () => invoke('state:load'),setPinned: (id: string, pinned: boolean) => invoke('item:set-pinned', id, pinned),deleteItem: (id: string) => invoke('item:delete', id),+ deleteBatchItems: (ids: string[]) => invoke('item:delete-batch', ids),clearItems: () => invoke('item:clear'),copyItem: (id: string) => invoke('item:copy', id),copySubitem: (req: import('../../shared/types').DragRequest) => invoke('item:copy-subitem', req),diff --git a/electron/store/ItemStore.ts b/electron/store/ItemStore.tsindex a1f298e..fb39803 100644--- a/electron/store/ItemStore.ts+++ b/electron/store/ItemStore.ts@@ -262,6 +262,28 @@ export class ItemStore {this.persist()}+ deleteBatch(ids: string[]): void {+ if (!ids || ids.length === 0) return+ const set = new Set(ids)+ const toRemove: ClipboardItem[] = []+ this.items = this.items.filter((it) => {+ if (set.has(it.id)) {+ toRemove.push(it)+ return false+ }+ return true+ })++ for (const removed of toRemove) {+ this.sigToId.delete(signature(removed.data))+ if (removed.data.kind === 'image') this.removeImageFile(removed.data.imageId)+ if (removed.data.kind === 'image-collection') {+ removed.data.images.forEach((img) => this.removeImageFile(img.imageId))+ }+ }+ this.persist()+ }+merge(sourceId: string, targetId: string): MergeResult {if (sourceId === targetId) return { ok: false }const srcIdx = this.items.findIndex(x => x.id === sourceId)diff --git a/shared/bridge.ts b/shared/bridge.tsindex a12b7b5..a12923c 100644--- a/shared/bridge.ts+++ b/shared/bridge.ts@@ -13,6 +13,7 @@ export interface EdgeApi {loadState: () => Promise<{ items: import('./types').ClipboardItemDto[]; settings: Settings; version: string; isStoreBuild?: boolean }>setPinned: (id: string, pinned: boolean) => Promise<import('./types').ClipboardItemDto[]>deleteItem: (id: string) => Promise<import('./types').ClipboardItemDto[]>+ deleteBatchItems: (ids: string[]) => Promise<import('./types').ClipboardItemDto[]>clearItems: () => Promise<import('./types').ClipboardItemDto[]>removeSubitem: (req: DragRequest) => Promise<boolean>copyItem: (id: string) => Promise<boolean>diff --git a/shared/ipc.ts b/shared/ipc.tsindex eb85b37..5233a90 100644--- a/shared/ipc.ts+++ b/shared/ipc.ts@@ -25,6 +25,9 @@ export interface InvokeMap {/** Delete a single item (and its image file if present). */'item:delete': { args: [id: string]; result: ClipboardItemDto[] }+ /** Delete a batch of items in a single atomic operation. */+ 'item:delete-batch': { args: [ids: string[]]; result: ClipboardItemDto[] }+/** Delete every unpinned item. */'item:clear': { args: []; result: ClipboardItemDto[] }diff --git a/src/store/appStore.ts b/src/store/appStore.tsindex 898224d..886b6ee 100644--- a/src/store/appStore.ts+++ b/src/store/appStore.ts@@ -340,10 +340,7 @@ export const useStore = create<AppState>((set, get) => ({} else {const idSet = new Set(ids)set({ items: get().items.filter((it) => !idSet.has(it.id)) })- let items = get().items- for (const id of ids) {- items = await edge.deleteItem(id)- }+ const items = await edge.deleteBatchItems(ids)set({ items })}},