Page MenuHomePhorge

D15447.1765041909.diff
No OneTemporary

Size
5 KB
Referenced Files
None
Subscribers
None

D15447.1765041909.diff

diff --git a/native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java b/native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java
--- a/native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java
+++ b/native/android/app/src/main/java/app/comm/android/notifications/CommNotificationsHandler.java
@@ -309,10 +309,7 @@
try {
int farcasterBadgeCount = Integer.parseInt(farcasterBadge);
String farcasterUnreadCountKey = String.join(
- MMKV_KEY_SEPARATOR,
- MMKV_KEYSERVER_PREFIX,
- MMKV_FARCASTER_KEY,
- MMKV_UNREAD_COUNT_SUFFIX);
+ MMKV_KEY_SEPARATOR, MMKV_FARCASTER_KEY, MMKV_UNREAD_COUNT_SUFFIX);
CommMMKV.setInt(farcasterUnreadCountKey, farcasterBadgeCount);
} catch (NumberFormatException e) {
Log.w("COMM", "Invalid Farcaster badge count", e);
@@ -350,6 +347,14 @@
totalUnreadCount += unreadCount;
}
+ // calculate unread count from Farcaster
+ String farcasterUnreadCountKey = String.join(
+ MMKV_KEY_SEPARATOR, MMKV_FARCASTER_KEY, MMKV_UNREAD_COUNT_SUFFIX);
+ Integer farcasterUnreadCount = CommMMKV.getInt(farcasterUnreadCountKey, -1);
+ if (farcasterUnreadCount != null) {
+ totalUnreadCount += farcasterUnreadCount;
+ }
+
totalUnreadCount +=
CommMMKV.getStringSet(CommMMKV.notifsStorageUnreadThickThreadsKey())
.length;
diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
--- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
+++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
@@ -25,6 +25,13 @@
using namespace facebook::react;
+// Those and future MMKV-related constants should match
+// similar constants in NotificationService.mm and CommNotificationsHandler.java
+const std::string MMKV_KEY_SEPARATOR = ".";
+const std::string MMKV_KEYSERVER_PREFIX = "KEYSERVER";
+const std::string MMKV_UNREAD_COUNT_SUFFIX = "UNREAD_COUNT";
+const std::string MMKV_FARCASTER_ID = "FARCASTER";
+
jsi::Value CommCoreModule::updateDraft(
jsi::Runtime &rt,
jsi::String key,
@@ -1335,7 +1342,14 @@
for (auto idx = 0; idx < data.size(rt); idx++) {
auto dataItem = data.getValueAtIndex(rt, idx).asObject(rt);
std::string id = dataItem.getProperty(rt, "id").asString(rt).utf8(rt);
- std::string storageKey = "KEYSERVER." + id + ".UNREAD_COUNT";
+ std::string storageKey;
+ if (id == MMKV_FARCASTER_ID) {
+ storageKey =
+ MMKV_FARCASTER_ID + MMKV_KEY_SEPARATOR + MMKV_UNREAD_COUNT_SUFFIX;
+ } else {
+ storageKey = MMKV_KEYSERVER_PREFIX + MMKV_KEY_SEPARATOR + id +
+ MMKV_KEY_SEPARATOR + MMKV_UNREAD_COUNT_SUFFIX;
+ }
int unreadCount = dataItem.getProperty(rt, "unreadCount").asNumber();
dataVectorCpp.push_back({storageKey, unreadCount});
@@ -1368,7 +1382,14 @@
std::vector<std::string> keysToDeleteCpp{};
for (auto idx = 0; idx < idsToDelete.size(rt); idx++) {
std::string id = idsToDelete.getValueAtIndex(rt, idx).asString(rt).utf8(rt);
- std::string storageKey = "KEYSERVER." + id + ".UNREAD_COUNT";
+ std::string storageKey;
+ if (id == MMKV_FARCASTER_ID) {
+ storageKey =
+ MMKV_FARCASTER_ID + MMKV_KEY_SEPARATOR + MMKV_UNREAD_COUNT_SUFFIX;
+ } else {
+ storageKey = MMKV_KEYSERVER_PREFIX + MMKV_KEY_SEPARATOR + id +
+ MMKV_KEY_SEPARATOR + MMKV_UNREAD_COUNT_SUFFIX;
+ }
keysToDeleteCpp.push_back(storageKey);
}
@@ -1406,7 +1427,14 @@
try {
for (const auto &id : idsCpp) {
- std::string storageKey = "KEYSERVER." + id + ".UNREAD_COUNT";
+ std::string storageKey;
+ if (id == MMKV_FARCASTER_ID) {
+ storageKey = MMKV_FARCASTER_ID + MMKV_KEY_SEPARATOR +
+ MMKV_UNREAD_COUNT_SUFFIX;
+ } else {
+ storageKey = MMKV_KEYSERVER_PREFIX + MMKV_KEY_SEPARATOR + id +
+ MMKV_KEY_SEPARATOR + MMKV_UNREAD_COUNT_SUFFIX;
+ }
std::optional<int> unreadCount = CommMMKV::getInt(storageKey, -1);
if (!unreadCount.has_value()) {
diff --git a/native/ios/NotificationService/NotificationService.mm b/native/ios/NotificationService/NotificationService.mm
--- a/native/ios/NotificationService/NotificationService.mm
+++ b/native/ios/NotificationService/NotificationService.mm
@@ -536,8 +536,7 @@
content.userInfo[@"badge"]) {
int farcasterBadgeCount = [content.userInfo[@"badge"] intValue];
std::string farcasterUnreadCountKey = joinStrings(
- mmkvKeySeparator,
- {mmkvKeyserverPrefix, mmkvFarcasterKey, mmkvUnreadCountSuffix});
+ mmkvKeySeparator, {mmkvFarcasterKey, mmkvUnreadCountSuffix});
comm::CommMMKV::setInt(farcasterUnreadCountKey, farcasterBadgeCount);
}
@@ -553,7 +552,7 @@
std::string([content.userInfo[threadIDKey] UTF8String]));
}
- // calculate unread counts from keyservers and Farcaster
+ // calculate unread counts from keyservers
int totalUnreadCount = 0;
std::vector<std::string> allKeys = comm::CommMMKV::getAllKeys();
for (const auto &key : allKeys) {
@@ -574,6 +573,15 @@
totalUnreadCount += unreadCount.value();
}
+ // calculate unread count from Farcaster
+ std::string farcasterUnreadCountKey =
+ joinStrings(mmkvKeySeparator, {mmkvFarcasterKey, mmkvUnreadCountSuffix});
+ std::optional<int> farcasterUnreadCount =
+ comm::CommMMKV::getInt(farcasterUnreadCountKey, -1);
+ if (farcasterUnreadCount.has_value()) {
+ totalUnreadCount += farcasterUnreadCount.value();
+ }
+
// calculate unread counts from thick threads
totalUnreadCount += comm::CommMMKV::getStringSet(
comm::CommMMKV::notifsStorageUnreadThickThreadsKey)

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 6, 5:25 PM (18 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5839778
Default Alt Text
D15447.1765041909.diff (5 KB)

Event Timeline