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