Fix a potential race condition when redacting a message. (#3061)

* Refactor the timeline item menu action provider.

- Move it into its own struct.
- Use an item, not an ID so it doesn't randomly change.
- Move permissions into the room screen view model.

* Use the stable ID when redacting/editing/forwarding a message.

Just like we do when fetching the item in the actions menu.
This commit is contained in:
Doug
2024-07-18 15:14:38 +01:00
committed by GitHub
parent 2fb7f65957
commit 6339fe2bf0
12 changed files with 337 additions and 275 deletions
@@ -57,7 +57,12 @@ struct RoomScreen: View {
.alert(item: $context.alertInfo)
.sheet(item: $context.debugInfo) { TimelineItemDebugView(info: $0) }
.sheet(item: $context.actionMenuInfo) { info in
context.viewState.timelineItemMenuActionProvider?(info.item.id).map { actions in
let actions = TimelineItemMenuActionProvider(timelineItem: info.item,
canCurrentUserRedactSelf: context.viewState.canCurrentUserRedactSelf,
canCurrentUserRedactOthers: context.viewState.canCurrentUserRedactOthers,
isDM: context.viewState.isEncryptedOneToOneRoom,
isViewSourceEnabled: context.viewState.isViewSourceEnabled).makeActions()
if let actions {
TimelineItemMenu(item: info.item, actions: actions)
.environmentObject(context)
}