Skip to content

Commit 97cf00e

Browse files
committed
Pinned events: add unpin action
1 parent 6cf64b2 commit 97cf00e

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesPresenter.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ class MessagesPresenter @AssistedInject constructor(
281281
TimelineItemAction.ReportContent -> handleReportAction(targetEvent)
282282
TimelineItemAction.EndPoll -> handleEndPollAction(targetEvent, timelineState)
283283
TimelineItemAction.Pin -> handlePinAction(targetEvent)
284+
TimelineItemAction.Unpin -> handleUnpinAction(targetEvent)
284285
}
285286
}
286287

@@ -291,6 +292,13 @@ class MessagesPresenter @AssistedInject constructor(
291292
}
292293
}
293294

295+
private suspend fun handleUnpinAction(targetEvent: TimelineItem.Event) {
296+
if (targetEvent.eventId == null) return
297+
timelineController.invokeOnCurrentTimeline {
298+
unpinEvent(targetEvent.eventId)
299+
}
300+
}
301+
294302
private fun CoroutineScope.toggleReaction(
295303
emoji: String,
296304
eventId: EventId,

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/actionlist/model/TimelineItemAction.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@ sealed class TimelineItemAction(
4040
data object ReportContent : TimelineItemAction(CommonStrings.action_report_content, CompoundDrawables.ic_compound_chat_problem, destructive = true)
4141
data object EndPoll : TimelineItemAction(CommonStrings.action_end_poll, CompoundDrawables.ic_compound_polls_end)
4242
data object Pin : TimelineItemAction(CommonStrings.action_pin, CompoundDrawables.ic_compound_pin)
43+
//TODO use the Unpin compound icon when available.
44+
data object Unpin : TimelineItemAction(CommonStrings.action_unpin, CompoundDrawables.ic_compound_pin)
4345
}

libraries/ui-strings/src/main/res/values/localazy.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
<string name="action_take_photo">"Take photo"</string>
111111
<string name="action_tap_for_options">"Tap for options"</string>
112112
<string name="action_try_again">"Try again"</string>
113+
<string name="action_unpin">"Unpin"</string>
113114
<string name="action_view_source">"View source"</string>
114115
<string name="action_yes">"Yes"</string>
115116
<string name="common_about">"About"</string>

0 commit comments

Comments
 (0)