addDeprecatedInfo function
Implementation
List<Feeds> addDeprecatedInfo(List<Feeds> chats) {
Map<String, String> latestDIDs = {};
for (var chat in chats) {
if (isValidCAIP10NFTAddress(chat.did)) {
List<String> didParts = chat.did!.split(':');
String didWithoutTimestamp = didParts.sublist(0, 5).join(':');
String timestamp = didParts[5];
if (!latestDIDs.containsKey(didWithoutTimestamp) ||
timestamp.compareTo(
latestDIDs[didWithoutTimestamp].toString().split(':')[5]) >
0) {
latestDIDs[didWithoutTimestamp] = chat.did!;
}
}
}
for (var chat in chats) {
if (isValidCAIP10NFTAddress(chat.did)) {
List<String> didParts = chat.did!.split(':');
String didWithoutTimestamp = didParts.sublist(0, 5).join(':');
if (latestDIDs[didWithoutTimestamp] != chat.did!) {
chat.deprecated = true;
chat.deprecatedCode = 'NFT Owner Changed';
}
}
}
return chats;
}