updateRecentChat method
dynamic
updateRecentChat(
- String jid
)
Implementation
updateRecentChat(String jid) {
//updateArchiveRecentChat(jid);
getRecentChatOfJid(jid).then((recent) {
final index = recentChats.indexWhere((chat) => chat.jid == jid);
debugPrint("dashboard index--> $index");
if (recent != null) {
if (!recent.isChatArchived.checkNull()) {
if (index.isNegative) {
recentChats.insert(0, recent);
} else {
var lastPinnedChat =
recentChats.lastIndexWhere((element) => element.isChatPinned!);
var nxtIndex = lastPinnedChat.isNegative ? 0 : (lastPinnedChat + 1);
if (recentChats[index].isChatPinned!) {
recentChats.removeAt(index);
recentChats.insert(index, recent);
} else {
recentChats.removeAt(index);
recentChats.insert(nxtIndex, recent);
recentChats.refresh();
}
}
} else {
if (!index.isNegative) {
recentChats.removeAt(index);
}
}
checkArchiveList(recent);
} else {
if (!index.isNegative) {
recentChats.removeAt(index);
}
}
recentChats.refresh();
});
}