Skip to content

fix(frontend): rebuild swiper after single-image delete#229

Merged
lstein merged 1 commit into
masterfrom
lstein/fix/delete-image
May 17, 2026
Merged

fix(frontend): rebuild swiper after single-image delete#229
lstein merged 1 commit into
masterfrom
lstein/fix/delete-image

Conversation

@lstein
Copy link
Copy Markdown
Owner

@lstein lstein commented May 17, 2026

Summary

  • Single-image delete (control panel trash button) patched one slide and adjusted slideState in place, leaving neighbor slides with stale dataset.globalIndex values after the backend re-indexed.
  • After a few deletes, scrolling forward hit a slide whose stale index made resolveOffset wrap to 0 before the real last image was ever appended — the very last image of the album became unreachable.
  • Replaces the surgical patching in handleSuccessfulDelete with a full state.single_swiper.resetAllSlides() rebuild (matching the bookmark-delete path), and clamps currentGlobalIndex so deleting the last image lands on the new last image.

Positioning behaviour after delete:

  • Deleting the current image keeps currentGlobalIndex unchanged — the backend re-index slides the next image into that slot.
  • Deleting the last image clamps down to the new last.
  • Deleting the only image leaves an empty swiper.
  • In search mode: splice the result, decrement subsequent .index values, clamp currentSearchIndex so the next result fills the slot; exit search mode if results become empty.

Test plan

  • Delete a middle image — current position stays, next image appears in its slot.
  • Delete the last image (highest index) — lands on the new last image.
  • Delete the only image in an album — swiper is empty.
  • In search mode, delete the current result — advances to next result; on last result, falls back to the new last.
  • After several deletes, scroll to the chronological end — the real last image is reachable.

Single-image deletion patched one slide and adjusted slideState in place,
leaving neighbor slides with stale dataset.globalIndex values after backend
reindexing. After a few deletes, scrolling forward hit a slide whose stale
index made resolveOffset wrap to 0 before the genuine last image was ever
appended. Replace the surgical patching with state.single_swiper.resetAllSlides(),
matching the bookmark-delete path, and clamp currentGlobalIndex so that
deleting the last image lands on the new last image.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lstein lstein merged commit 0a55c28 into master May 17, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant