Pinned events: add unpin action

This commit is contained in:
ganfra 2024-07-30 11:52:45 +02:00
parent 6cf64b263e
commit 97cf00ec96
3 changed files with 11 additions and 0 deletions

View file

@ -281,6 +281,7 @@ class MessagesPresenter @AssistedInject constructor(
TimelineItemAction.ReportContent -> handleReportAction(targetEvent)
TimelineItemAction.EndPoll -> handleEndPollAction(targetEvent, timelineState)
TimelineItemAction.Pin -> handlePinAction(targetEvent)
TimelineItemAction.Unpin -> handleUnpinAction(targetEvent)
}
}
@ -291,6 +292,13 @@ class MessagesPresenter @AssistedInject constructor(
}
}
private suspend fun handleUnpinAction(targetEvent: TimelineItem.Event) {
if (targetEvent.eventId == null) return
timelineController.invokeOnCurrentTimeline {
unpinEvent(targetEvent.eventId)
}
}
private fun CoroutineScope.toggleReaction(
emoji: String,
eventId: EventId,

View file

@ -40,4 +40,6 @@ sealed class TimelineItemAction(
data object ReportContent : TimelineItemAction(CommonStrings.action_report_content, CompoundDrawables.ic_compound_chat_problem, destructive = true)
data object EndPoll : TimelineItemAction(CommonStrings.action_end_poll, CompoundDrawables.ic_compound_polls_end)
data object Pin : TimelineItemAction(CommonStrings.action_pin, CompoundDrawables.ic_compound_pin)
//TODO use the Unpin compound icon when available.
data object Unpin : TimelineItemAction(CommonStrings.action_unpin, CompoundDrawables.ic_compound_pin)
}