Bento, the office suite that fits in a file
TypeScript mit-licenseofficeoffice-365office-suiteoffice-toolsoffice365open-sourcepowerpointself-hostedsingle-page-appslidesslideshareslideshowslideshow-galleryslideshow-makerslideshows
Fix #30: deleting a slide could empty the deck entirely
nyblneteed9ad87cc10
diff --git a/slides/src/editor/editor.ts b/slides/src/editor/editor.tsindex 0c913fe0..62508336 100644--- a/slides/src/editor/editor.ts+++ b/slides/src/editor/editor.ts@@ -1219,11 +1219,19 @@ export class Editor {}private deleteSlide(i: number) {- if (this.store.doc.slides.length <= 1) return this.toast(t('A deck needs at least one slide'))const target = this.store.doc.slides[i]+ if (!target) return// dependents: states of this slide, and element links pointing at itconst states = this.store.doc.slides.filter((s) => s.stateOf === target.id)const doomedIds = new Set([target.id, ...states.map((s) => s.id)])+ // "A deck needs at least one slide" has to be checked against what will+ // SURVIVE, not against the current count: deleting a parent takes its+ // interactive states with it, so one slide + one state (length 2) sailed+ // past a `length <= 1` test and then deleted BOTH — leaving a deck with+ // zero slides and an editor with nothing to render (issue #30). States+ // don't count as survivors: they're unreachable except through a parent.+ const survivesLinear = this.store.doc.slides.some((s) => !s.stateOf && !doomedIds.has(s.id))+ if (!survivesLinear) return this.toast(t('A deck needs at least one slide'))let linkCount = 0for (const s of this.store.doc.slides) {if (doomedIds.has(s.id)) continue