Skip to content

Commit

Permalink
feat: Show chat is push notifiable
Browse files Browse the repository at this point in the history
  • Loading branch information
kornsitti committed Dec 10, 2024
1 parent f3482fc commit 40865b4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion lib/presentation/screen/channel_list/channel_list_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ class _ChannelListScreenState extends State<ChannelListScreen> {
AmityChannelSortOption _sort = AmityChannelSortOption.LAST_ACTIVITY;
List<String>? _tags;
List<String>? _excludingTags;
bool? isPushNotifiable;

@override
void initState() {
resetLiveCollection(isReset: false);
scrollcontroller.addListener(pagination);
fetchNotificationSettings();
super.initState();
}

Expand All @@ -47,6 +49,14 @@ class _ChannelListScreenState extends State<ChannelListScreen> {
}
}

void fetchNotificationSettings() async {
final settings = await AmityNotification().user().getSettings();
final chatModuleSetting = settings.events?.whereType<Chat>().firstOrNull;
setState(() {
isPushNotifiable = (settings.isEnabled ?? true) && (chatModuleSetting?.isEnabled ?? true);
});
}

void resetLiveCollection({ bool isReset = true }) async {
if (isReset) {
_channelLiveCollection.getStreamController().stream;
Expand Down Expand Up @@ -85,6 +95,12 @@ class _ChannelListScreenState extends State<ChannelListScreen> {
appBar: AppBar(title: const Text('Channel List ')),
body: Column(
children: [
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
width: double.infinity,
color: Colors.grey[200],
child: Text("chat.push_notification.enable: ${isPushNotifiable ?? "unknown"}"),
),
Container(
padding: const EdgeInsets.all(12),
child: TextFormField(
Expand Down Expand Up @@ -304,7 +320,7 @@ class _ChannelListScreenState extends State<ChannelListScreen> {
alignment: Alignment.center,
child: _channelLiveCollection.isFetching
? const CircularProgressIndicator()
: const Text('No Post'),
: const Text('No channel found'),
),
),
if (_channelLiveCollection.isFetching && amityChannels.isNotEmpty)
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_social_sample_app
description: Demonstrates how to use the flutter_application_1 plugin.
version: 1.1.50+67
version: 1.1.51+68



Expand Down

0 comments on commit 40865b4

Please sign in to comment.