Skip to content

Commit

Permalink
Add detach to spotlight (#5157)
Browse files Browse the repository at this point in the history
* add detach to spotlight

* typo
  • Loading branch information
benjaminpkane authored Nov 20, 2024
1 parent 2ae21fe commit 453fbd0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions app/packages/core/src/components/Grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ function Grid() {
looker?.destroy();
lookerStore.delete(id.description);
},
detach: (id) => {
const looker = lookerStore.get(id.description);
looker?.detach();
},
onItemClick: setSample,
retainItems: true,
rowAspectRatioThreshold: threshold,
Expand Down
6 changes: 3 additions & 3 deletions app/packages/spotlight/src/row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default class Row<K, V> {
}

destroy(destroyItems = false) {
destroyItems && this.#destroyItems();
this.#destroyItems(destroyItems);
this.#aborter.abort();
}

Expand Down Expand Up @@ -231,8 +231,8 @@ export default class Row<K, V> {
return set.size === ONE ? this.#row[ZERO].item.aspectRatio : null;
}

#destroyItems() {
const destroy = this.#config.destroy;
#destroyItems(destroyItems = false) {
const destroy = destroyItems ? this.#config.destroy : this.#config.detach;
if (!destroy) {
return;
}
Expand Down
1 change: 1 addition & 0 deletions app/packages/spotlight/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export type Request<K, V> = (key: K) => Promise<{
export interface SpotlightConfig<K, V> {
at?: At;
destroy?: (id: ID) => void;
detach?: (id: ID) => void;
get: Get<K, V>;
key: K;
offset?: number;
Expand Down

0 comments on commit 453fbd0

Please sign in to comment.