Skip to main content

Channel Do Not Disturb

Channel-level Do Not Disturb controls whether a channel should alert the user. Messages are still received, stored, and counted as unread; only alert behavior changes.

Use ChannelProvider for the default channel list actions, or call the underlying channel API directly when building a custom screen.

Mute and unmute a channel

Dart
final provider = context.read<ChannelProvider>();

final error = await provider.muteChannel(channel);
if (error != null && !error.isSuccess) {
debugPrint(error.message ?? error.reason ?? 'Mute failed');
}

To restore alerts:

Dart
final error = await provider.unmuteChannel(channel);
if (error != null && !error.isSuccess) {
debugPrint(error.message ?? error.reason ?? 'Unmute failed');
}

ChannelProvider reloads the channel list after a successful mute or unmute operation so the UI reflects the latest channel state.

Check the channel state

Dart
final muted = channel.notificationLevel == ChannelNoDisturbLevel.blocked;

The default ChannelPage long-press menu includes a mute or unmute action based on this value.

Customize actions

ChannelPage exposes action hooks for custom menus and custom operation handling.

Dart
ChannelPage(
channelActionsBuilder: (channel) {
final muted = channel.notificationLevel == ChannelNoDisturbLevel.blocked;
return [
ChannelAction(
type: muted ? ChannelActionType.unmute : ChannelActionType.mute,
label: muted ? 'Unmute' : 'Mute',
icon: muted
? Icons.notifications_active_outlined
: Icons.notifications_off_outlined,
),
const ChannelAction(
type: ChannelActionType.delete,
label: 'Delete',
icon: Icons.delete_outline,
destructive: true,
),
];
},
onChannelAction: (context, channel, action) async {
final provider = context.read<ChannelProvider>();
final error = switch (action) {
ChannelActionType.mute => await provider.muteChannel(channel),
ChannelActionType.unmute => await provider.unmuteChannel(channel),
ChannelActionType.pin => await provider.pinChannel(channel),
ChannelActionType.unpin => await provider.unpinChannel(channel),
ChannelActionType.delete => await provider.deleteChannel(channel),
};

if (error != null && !error.isSuccess && context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(error.message ?? error.reason ?? 'Action failed')),
);
}
},
);

Swipe actions

Mute and unmute can also be exposed through the default swipe action configuration.

Dart
ChannelPage(
config: const ChannelConfig(
itemConfig: ChannelItemConfig(
swipeActionsConfig: ChannelSwipeActionsConfig(
actions: [
ChannelActionType.pin,
ChannelActionType.mute,
ChannelActionType.delete,
],
),
),
),
);

The swipe host converts mute to unmute automatically when the current channel is already muted.

Sync events

EngineProvider publishes channel Do Not Disturb sync events from the Nexconn SDK. Listen to channelNoDisturbLevelSyncNotifier when another client may update the same user's channel settings.

Dart
final engineProvider = context.read<EngineProvider>();

void onSync() {
final event = engineProvider.channelNoDisturbLevelSyncNotifier.value;
if (event != null) {
context.read<ChannelProvider>().reload();
}
}

engineProvider.channelNoDisturbLevelSyncNotifier.addListener(onSync);

Remove the listener when the widget is disposed.

Local notification behavior

Channel Do Not Disturb affects local notification decisions only when your app chooses to honor the channel state before displaying a local notification. The built-in channel UI updates the mute state and indicators; remote push behavior depends on your server and push configuration.