refreshChannels method
Future<void>
refreshChannels(
)
Implementation
Future<void> refreshChannels() async {
log("refreshChannels...");
await channelRepoImp.fetchChannelsList((data, error) async {
if (error == null && data != null) {
_amityChannelList.clear();
_addUnreadCountToEachChannel(data);
if (data.channels != null) {
for (var channel in data.channels!) {
_addLatestMessage(channel);
_amityChannelList.add(channel);
String key =
channel.channelId! + AmityCoreClient.getCurrentUser().userId!;
if (channelUserMap[key] != null) {
var count =
channel.messageCount! - channelUserMap[key]!.readToSegment!;
channel.setUnreadCount(count);
}
}
}
} else {
log(error.toString());
await AmityDialog()
.showAlertErrorDialog(title: "Error!", message: error!);
}
notifyListeners();
});
}