fix(core): streak expiration
Signed-off-by: rhunk <101876869+rhunk@users.noreply.github.com>
This commit is contained in:
@@ -26,6 +26,8 @@ data class FriendFeedEntry(
|
||||
var friendLinkType: Int? = null,
|
||||
var bitmojiAvatarId: String? = null,
|
||||
var bitmojiSelfieId: String? = null,
|
||||
var streakCount: Int? = null,
|
||||
var streakExpirationTimestampMs: Long? = null,
|
||||
) : DatabaseObject {
|
||||
@SuppressLint("Range")
|
||||
override fun write(cursor: Cursor) {
|
||||
@@ -47,6 +49,9 @@ data class FriendFeedEntry(
|
||||
friendLinkType = getIntOrNull("friendLinkType")
|
||||
bitmojiAvatarId = getStringOrNull("bitmojiAvatarId")
|
||||
bitmojiSelfieId = getStringOrNull("bitmojiSelfieId")
|
||||
|
||||
streakCount = getIntOrNull("streak_count")
|
||||
streakExpirationTimestampMs = getLongOrNull("streak_expiration_timestamp_ms")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,6 +337,11 @@ class SnapEnhance {
|
||||
}
|
||||
|
||||
private fun syncRemote() {
|
||||
val myUserId = appContext.database.myUserId
|
||||
val streakEntries = appContext.database.getFeedEntries(Int.MAX_VALUE, whereClause = "streak_count IS NOT NULL AND streak_count > 0").associate {
|
||||
(it.friendUserId ?: it.participants?.firstOrNull { it != myUserId }) to it
|
||||
}.filter { it.key != null }
|
||||
|
||||
appContext.bridgeClient.sync(object : SyncCallback.Stub() {
|
||||
override fun syncFriend(uuid: String): String? {
|
||||
return appContext.database.getFriendInfo(uuid)?.let {
|
||||
@@ -352,7 +357,12 @@ class SnapEnhance {
|
||||
expirationTimestamp = it.streakExpirationTimestamp,
|
||||
length = it.streakLength
|
||||
)
|
||||
} else null
|
||||
} else streakEntries[it.userId]?.let {
|
||||
FriendStreaks(
|
||||
expirationTimestamp = it.streakExpirationTimestampMs ?: return@let null,
|
||||
length = it.streakCount ?: return@let null
|
||||
)
|
||||
}
|
||||
).toSerialized()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,11 +283,11 @@ class DatabaseAccess(
|
||||
} ?: emptyList()
|
||||
}
|
||||
|
||||
fun getFeedEntries(limit: Int): List<FriendFeedEntry> {
|
||||
fun getFeedEntries(limit: Int, whereClause: String? = null): List<FriendFeedEntry> {
|
||||
val entries = mutableListOf<FriendFeedEntry>()
|
||||
return useDatabase(DatabaseType.ARROYO)?.performOperation {
|
||||
safeRawQuery(
|
||||
"SELECT * FROM feed_entry ORDER BY last_updated_timestamp DESC LIMIT ?",
|
||||
"SELECT * FROM feed_entry ${whereClause?.let { "WHERE $it" }.orEmpty()} ORDER BY last_updated_timestamp DESC LIMIT ?",
|
||||
arrayOf(limit.toString())
|
||||
)?.use { query ->
|
||||
while (query.moveToNext()) {
|
||||
|
||||
Reference in New Issue
Block a user