From 5e3049158e190cce0821180193bf216063ec391b Mon Sep 17 00:00:00 2001 From: Daniel Sockwell Date: Fri, 20 Mar 2020 22:10:42 -0400 Subject: [PATCH] [Glitch] Fix frontend crash when deleting announcements Port 577f74ad87dd9e6a02c88e1f50d587a0bf09afc4 to glitch-soc Signed-off-by: Thibaut Girka --- .../features/getting_started/components/announcements.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/javascript/flavours/glitch/features/getting_started/components/announcements.js b/app/javascript/flavours/glitch/features/getting_started/components/announcements.js index 48e1766e20..5f6e6d84c3 100644 --- a/app/javascript/flavours/glitch/features/getting_started/components/announcements.js +++ b/app/javascript/flavours/glitch/features/getting_started/components/announcements.js @@ -389,7 +389,7 @@ class Announcements extends ImmutablePureComponent { _markAnnouncementAsRead () { const { dismissAnnouncement, announcements } = this.props; const { index } = this.state; - const announcement = announcements.get(index); + const announcement = announcements.get(index) || announcements.get(index - 1); if (!announcement.get('read')) dismissAnnouncement(announcement.get('id')); } @@ -407,7 +407,7 @@ class Announcements extends ImmutablePureComponent { render () { const { announcements, intl } = this.props; - const { index } = this.state; + const index = this.state.index < announcements.size ? this.state.index : announcements.size - 1; if (announcements.isEmpty()) { return null;