Skip to content

Commit ff23f48

Browse files
authored
Expose all the default message actions (#711)
* Expose all default `MessageActions` * Add docs and make extension public * Update CHANGELOG.md
1 parent 00c91d8 commit ff23f48

File tree

2 files changed

+43
-23
lines changed

2 files changed

+43
-23
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
33

44
# Upcoming
55

6+
### ✅ Added
7+
- Exposes all the default message actions [#711](https://github.com/GetStream/stream-chat-swiftui/pull/711)
68
### 🐞 Fixed
79
- Use bright color for typing indicator animation in dark mode [#702](https://github.com/GetStream/stream-chat-swiftui/pull/702)
810
- Refresh quoted message preview when the quoted message is deleted [#705](https://github.com/GetStream/stream-chat-swiftui/pull/705)

Sources/StreamChatSwiftUI/ChatChannel/Reactions/MessageActions/DefaultMessageActions.swift

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@
55
import StreamChat
66
import SwiftUI
77

8-
extension MessageAction {
8+
// MARK: - Default Message Actions
9+
10+
public extension MessageAction {
911
/// Returns the default message actions.
1012
///
1113
/// - Parameters:
1214
/// - message: the current message.
1315
/// - chatClient: the chat client.
1416
/// - onDimiss: called when the action is executed.
1517
/// - Returns: array of `MessageAction`.
16-
public static func defaultActions<Factory: ViewFactory>(
18+
static func defaultActions<Factory: ViewFactory>(
1719
factory: Factory,
1820
for message: ChatMessage,
1921
channel: ChatChannel,
@@ -229,9 +231,8 @@ extension MessageAction {
229231
return messageActions
230232
}
231233

232-
// MARK: - private
233-
234-
private static func copyMessageAction(
234+
/// The action to copy the message text.
235+
static func copyMessageAction(
235236
for message: ChatMessage,
236237
onFinish: @escaping (MessageActionInfo) -> Void
237238
) -> MessageAction {
@@ -255,7 +256,8 @@ extension MessageAction {
255256
return copyAction
256257
}
257258

258-
private static func editMessageAction(
259+
/// The action to edit the message.
260+
static func editMessageAction(
259261
for message: ChatMessage,
260262
channel: ChatChannel,
261263
onFinish: @escaping (MessageActionInfo) -> Void
@@ -279,7 +281,8 @@ extension MessageAction {
279281
return editAction
280282
}
281283

282-
private static func pinMessageAction(
284+
/// The action to pin the message.
285+
static func pinMessageAction(
283286
for message: ChatMessage,
284287
channel: ChatChannel,
285288
chatClient: ChatClient,
@@ -318,7 +321,8 @@ extension MessageAction {
318321
return pinAction
319322
}
320323

321-
private static func unpinMessageAction(
324+
/// The action to unpin the message.
325+
static func unpinMessageAction(
322326
for message: ChatMessage,
323327
channel: ChatChannel,
324328
chatClient: ChatClient,
@@ -357,7 +361,8 @@ extension MessageAction {
357361
return pinAction
358362
}
359363

360-
private static func replyAction(
364+
/// The action to reply to the message
365+
static func replyAction(
361366
for message: ChatMessage,
362367
channel: ChatChannel,
363368
onFinish: @escaping (MessageActionInfo) -> Void
@@ -381,7 +386,8 @@ extension MessageAction {
381386
return replyAction
382387
}
383388

384-
private static func threadReplyAction<Factory: ViewFactory>(
389+
/// The action to reply to the message in a thread
390+
static func threadReplyAction<Factory: ViewFactory>(
385391
factory: Factory,
386392
for message: ChatMessage,
387393
channel: ChatChannel
@@ -404,7 +410,8 @@ extension MessageAction {
404410
return replyThread
405411
}
406412

407-
private static func deleteMessageAction(
413+
/// The action to delete the message.
414+
static func deleteMessageAction(
408415
for message: ChatMessage,
409416
channel: ChatChannel,
410417
chatClient: ChatClient,
@@ -449,7 +456,8 @@ extension MessageAction {
449456
return deleteMessage
450457
}
451458

452-
private static func flagMessageAction(
459+
/// The action to flag the message.
460+
static func flagMessageAction(
453461
for message: ChatMessage,
454462
channel: ChatChannel,
455463
chatClient: ChatClient,
@@ -493,8 +501,9 @@ extension MessageAction {
493501

494502
return flagMessage
495503
}
496-
497-
private static func markAsUnreadAction(
504+
505+
/// The action to mark the message as unread.
506+
static func markAsUnreadAction(
498507
for message: ChatMessage,
499508
channel: ChatChannel,
500509
chatClient: ChatClient,
@@ -530,7 +539,8 @@ extension MessageAction {
530539
return unreadAction
531540
}
532541

533-
private static func markThreadAsUnreadAction(
542+
/// The action to mark the thread as unread.
543+
static func markThreadAsUnreadAction(
534544
messageController: ChatMessageController,
535545
message: ChatMessage,
536546
onFinish: @escaping (MessageActionInfo) -> Void,
@@ -562,7 +572,8 @@ extension MessageAction {
562572
return unreadAction
563573
}
564574

565-
private static func muteAction(
575+
/// The action to mute the user.
576+
static func muteAction(
566577
for message: ChatMessage,
567578
channel: ChatChannel,
568579
chatClient: ChatClient,
@@ -597,8 +608,9 @@ extension MessageAction {
597608

598609
return muteUser
599610
}
600-
601-
private static func blockUserAction(
611+
612+
/// The action to block the user
613+
static func blockUserAction(
602614
for message: ChatMessage,
603615
channel: ChatChannel,
604616
chatClient: ChatClient,
@@ -638,7 +650,8 @@ extension MessageAction {
638650
return blockUser
639651
}
640652

641-
private static func unmuteAction(
653+
/// The action to unmute the user.
654+
static func unmuteAction(
642655
for message: ChatMessage,
643656
channel: ChatChannel,
644657
chatClient: ChatClient,
@@ -673,8 +686,9 @@ extension MessageAction {
673686

674687
return unmuteUser
675688
}
676-
677-
private static func unblockUserAction(
689+
690+
/// The action to unblock the user.
691+
static func unblockUserAction(
678692
for message: ChatMessage,
679693
channel: ChatChannel,
680694
chatClient: ChatClient,
@@ -714,7 +728,8 @@ extension MessageAction {
714728
return unblockUser
715729
}
716730

717-
private static func resendMessageAction(
731+
/// The action to resend the message.
732+
static func resendMessageAction(
718733
for message: ChatMessage,
719734
channel: ChatChannel,
720735
chatClient: ChatClient,
@@ -753,7 +768,8 @@ extension MessageAction {
753768
return messageAction
754769
}
755770

756-
private static func messageNotSentActions(
771+
/// The actions for a message that was not sent.
772+
static func messageNotSentActions(
757773
for message: ChatMessage,
758774
channel: ChatChannel,
759775
chatClient: ChatClient,
@@ -783,6 +799,8 @@ extension MessageAction {
783799
return messageActions
784800
}
785801

802+
// MARK: - Helpers
803+
786804
private static func editAndDeleteActions(
787805
for message: ChatMessage,
788806
channel: ChatChannel,

0 commit comments

Comments
 (0)