about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch
diff options
context:
space:
mode:
authorDaniel Sockwell <dsockwell@gmail.com>2020-03-20 22:10:42 -0400
committerThibaut Girka <thib@sitedethib.com>2020-03-22 16:31:01 +0100
commit9da4bd098cac88c3e44157765adcff01445ba31a (patch)
treeb36d73f45175add7aa114bb42fca5a528a9b24a4 /app/javascript/flavours/glitch
parent0ff78befc6a067f4157648f229b4f2242d5a8082 (diff)
[Glitch] Fix frontend crash when deleting announcements
Port 8758221e7344645bc1357578ec1789aa7d46da08 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
Diffstat (limited to 'app/javascript/flavours/glitch')
-rw-r--r--app/javascript/flavours/glitch/features/getting_started/components/announcements.js4
1 files 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 48e1766e2..5f6e6d84c 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;