added permission types
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
class PermissionType {
|
||||
static const String sendMessage = "send-message";
|
||||
|
||||
static const String sendReaction = "send-reaction";
|
||||
|
||||
static const String sendLinks = "send-links";
|
||||
|
||||
static const String sendReply = "send-reply";
|
||||
|
||||
static const String freezeChannel = "freeze-channel";
|
||||
|
||||
static const String setChannelCooldown = "set-channel-cooldown";
|
||||
|
||||
static const String leaveChannel = "leave-channel";
|
||||
|
||||
static const String pinMessage = "pin-message";
|
||||
|
||||
static const String deleteAnyMessage = "delete-any-message";
|
||||
|
||||
static const String deleteOwnMessage = "delete-own-message";
|
||||
|
||||
static const String updateAnyMessage = "update-any-message";
|
||||
|
||||
static const String updateOwnMessage = "update-own-message";
|
||||
|
||||
static const String searchMessages = "search-messages";
|
||||
|
||||
static const String sendTypingEvents = "send-typing-events";
|
||||
|
||||
static const String uploadFile = "upload-file";
|
||||
|
||||
static const String deleteChannel = "delete-channel";
|
||||
|
||||
static const String updateChannel = "update-channel";
|
||||
|
||||
static const String updateChannelMembers = "update-channel-members";
|
||||
}
|
||||
@@ -36,6 +36,7 @@ export './src/core/util/extension.dart';
|
||||
export './src/db/chat_persistence_client.dart';
|
||||
export './src/event_type.dart';
|
||||
export './src/location.dart';
|
||||
export './src/permission_type.dart';
|
||||
export './src/ws/connection_status.dart';
|
||||
export 'src/client/channel.dart';
|
||||
export 'src/client/client.dart';
|
||||
|
||||
@@ -164,7 +164,6 @@ class MessageListView extends StatefulWidget {
|
||||
this.messageFilter,
|
||||
this.onMessageTap,
|
||||
this.onSystemMessageTap,
|
||||
this.pinPermissions = const [],
|
||||
this.showFloatingDateDivider = true,
|
||||
this.threadSeparatorBuilder,
|
||||
this.messageListController,
|
||||
@@ -276,9 +275,6 @@ class MessageListView extends StatefulWidget {
|
||||
/// Called when system message is tapped
|
||||
final OnMessageTap? onSystemMessageTap;
|
||||
|
||||
/// A List of user types that have permission to pin messages
|
||||
final List<String> pinPermissions;
|
||||
|
||||
/// Builder used to build the thread separator in case it's a thread view
|
||||
final WidgetBuilder? threadSeparatorBuilder;
|
||||
|
||||
@@ -301,6 +297,7 @@ class _MessageListViewState extends State<MessageListView> {
|
||||
int? _messageListLength;
|
||||
StreamChannelState? streamChannel;
|
||||
late StreamChatThemeData _streamTheme;
|
||||
late List<String> _userPermissions;
|
||||
|
||||
int get _initialIndex {
|
||||
final initialScrollIndex = widget.initialScrollIndex;
|
||||
@@ -960,7 +957,7 @@ class _MessageListViewState extends State<MessageListView> {
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
showPinButton: currentUserMember != null &&
|
||||
widget.pinPermissions.contains(currentUserMember.role),
|
||||
_userPermissions.contains(PermissionType.pinMessage),
|
||||
);
|
||||
|
||||
if (widget.parentMessageBuilder != null) {
|
||||
@@ -1159,7 +1156,7 @@ class _MessageListViewState extends State<MessageListView> {
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
showPinButton: currentUserMember != null &&
|
||||
widget.pinPermissions.contains(currentUserMember.role),
|
||||
_userPermissions.contains(PermissionType.pinMessage),
|
||||
);
|
||||
|
||||
if (widget.messageBuilder != null) {
|
||||
@@ -1239,6 +1236,9 @@ class _MessageListViewState extends State<MessageListView> {
|
||||
void didChangeDependencies() {
|
||||
final newStreamChannel = StreamChannel.of(context);
|
||||
_streamTheme = StreamChatTheme.of(context);
|
||||
_userPermissions =
|
||||
newStreamChannel.channel.state?.channelState.channel?.ownCapabilities ??
|
||||
[];
|
||||
|
||||
if (newStreamChannel != streamChannel) {
|
||||
streamChannel = newStreamChannel;
|
||||
|
||||
Reference in New Issue
Block a user