[Glitch] Fix frontend crash when deleting announcements
Port 577f74ad87 to glitch-soc
Signed-off-by: Thibaut Girka <thib@sitedethib.com>
			
			
This commit is contained in:
		
							parent
							
								
									e9338c7640
								
							
						
					
					
						commit
						5e3049158e
					
				
					 1 changed files with 2 additions and 2 deletions
				
			
		|  | @ -389,7 +389,7 @@ class Announcements extends ImmutablePureComponent { | ||||||
|   _markAnnouncementAsRead () { |   _markAnnouncementAsRead () { | ||||||
|     const { dismissAnnouncement, announcements } = this.props; |     const { dismissAnnouncement, announcements } = this.props; | ||||||
|     const { index } = this.state; |     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')); |     if (!announcement.get('read')) dismissAnnouncement(announcement.get('id')); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | @ -407,7 +407,7 @@ class Announcements extends ImmutablePureComponent { | ||||||
| 
 | 
 | ||||||
|   render () { |   render () { | ||||||
|     const { announcements, intl } = this.props; |     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()) { |     if (announcements.isEmpty()) { | ||||||
|       return null; |       return null; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue