@@ -27,6 +27,7 @@ import ViewSourceIcon from "@/icons/code.svg?react"
27
27
import DeleteIcon from "@/icons/delete.svg?react"
28
28
import PinIcon from "@/icons/pin.svg?react"
29
29
import ReportIcon from "@/icons/report.svg?react"
30
+ import RestoreTrashIcon from "@/icons/restore-trash.svg?react"
30
31
import ShareIcon from "@/icons/share.svg?react"
31
32
import UnpinIcon from "@/icons/unpin.svg?react"
32
33
@@ -85,6 +86,18 @@ export const useSecondaryItems = (
85
86
</ RoomContext > ,
86
87
} )
87
88
}
89
+ const onClickHideUnredacted = ( ) => {
90
+ closeModal ( )
91
+ roomCtx . store . setViewingRedacted ( evt , false )
92
+ }
93
+ const onClickUnredact = ( ) => {
94
+ closeModal ( )
95
+ if ( Object . entries ( evt . content ) . length > 0 ) {
96
+ roomCtx . store . setViewingRedacted ( evt , true )
97
+ } else {
98
+ client . requestEvent ( roomCtx . store , evt . event_id , true )
99
+ }
100
+ }
88
101
const onClickPin = ( pin : boolean ) => ( ) => {
89
102
closeModal ( )
90
103
client . pinMessage ( roomCtx . store , evt . event_id , pin )
@@ -146,6 +159,8 @@ export const useSecondaryItems = (
146
159
const canRedact = ! evt . redacted_by
147
160
&& ownPL >= redactEvtPL
148
161
&& ( evt . sender === client . userID || ownPL >= redactOtherPL )
162
+ // TODO check server admin status and room PLs
163
+ const canUnredact = Boolean ( evt . redacted_by )
149
164
150
165
return < >
151
166
< button onClick = { onClickViewSource } > < ViewSourceIcon /> { names && "View source" } </ button >
@@ -166,5 +181,10 @@ export const useSecondaryItems = (
166
181
title = { pendingTitle }
167
182
className = "redact-button"
168
183
> < DeleteIcon /> { names && "Remove" } </ button > }
184
+ { canUnredact && ( evt . viewing_redacted ? < button onClick = { onClickHideUnredacted } >
185
+ < DeleteIcon /> { names && "Hide content" }
186
+ </ button > : < button onClick = { onClickUnredact } >
187
+ < RestoreTrashIcon /> { names && "View content" }
188
+ </ button > ) }
169
189
</ >
170
190
}
0 commit comments