mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-21 15:48:26 +00:00
Fixed an edge case where an OpenGroup might not download it's image
This commit is contained in:
parent
0ed5c5825d
commit
8a4a9623cc
@ -318,6 +318,19 @@ public class GroupDatabase extends Database implements LokiOpenGroupDatabaseProt
|
|||||||
notifyConversationListListeners();
|
notifyConversationListListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasDownloadedProfilePicture(String groupId) {
|
||||||
|
try (Cursor cursor = databaseHelper.getReadableDatabase().query(TABLE_NAME, new String[]{AVATAR}, GROUP_ID + " = ?",
|
||||||
|
new String[] {groupId},
|
||||||
|
null, null, null))
|
||||||
|
{
|
||||||
|
if (cursor != null && cursor.moveToNext()) {
|
||||||
|
return !cursor.isNull(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void updateMembers(String groupId, List<Address> members) {
|
public void updateMembers(String groupId, List<Address> members) {
|
||||||
Collections.sort(members);
|
Collections.sort(members);
|
||||||
|
|
||||||
|
@ -321,6 +321,10 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
|||||||
DatabaseComponent.get(context).groupDatabase().updateProfilePicture(groupID, newValue)
|
DatabaseComponent.get(context).groupDatabase().updateProfilePicture(groupID, newValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun hasDownloadedProfilePicture(groupID: String): Boolean {
|
||||||
|
return DatabaseComponent.get(context).groupDatabase().hasDownloadedProfilePicture(groupID)
|
||||||
|
}
|
||||||
|
|
||||||
override fun getReceivedMessageTimestamps(): Set<Long> {
|
override fun getReceivedMessageTimestamps(): Set<Long> {
|
||||||
return SessionMetaProtocol.getTimestamps()
|
return SessionMetaProtocol.getTimestamps()
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,7 @@ interface StorageProtocol {
|
|||||||
// Open Group Metadata
|
// Open Group Metadata
|
||||||
fun updateTitle(groupID: String, newValue: String)
|
fun updateTitle(groupID: String, newValue: String)
|
||||||
fun updateProfilePicture(groupID: String, newValue: ByteArray)
|
fun updateProfilePicture(groupID: String, newValue: ByteArray)
|
||||||
|
fun hasDownloadedProfilePicture(groupID: String): Boolean
|
||||||
fun setUserCount(room: String, server: String, newValue: Int)
|
fun setUserCount(room: String, server: String, newValue: Int)
|
||||||
|
|
||||||
// Last Message Server ID
|
// Last Message Server ID
|
||||||
|
@ -117,6 +117,7 @@ class OpenGroupPoller(private val server: String, private val executorService: S
|
|||||||
) {
|
) {
|
||||||
val storage = MessagingModuleConfiguration.shared.storage
|
val storage = MessagingModuleConfiguration.shared.storage
|
||||||
val groupId = "$server.$roomToken"
|
val groupId = "$server.$roomToken"
|
||||||
|
val dbGroupId = GroupUtil.getEncodedOpenGroupID(groupId.toByteArray())
|
||||||
|
|
||||||
val existingOpenGroup = storage.getOpenGroup(roomToken, server)
|
val existingOpenGroup = storage.getOpenGroup(roomToken, server)
|
||||||
val publicKey = existingOpenGroup?.publicKey ?: return
|
val publicKey = existingOpenGroup?.publicKey ?: return
|
||||||
@ -157,8 +158,19 @@ class OpenGroupPoller(private val server: String, private val executorService: S
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start downloading the room image (if we don't have one or it's been updated)
|
if (
|
||||||
if (pollInfo.details?.imageId != null && pollInfo.details.imageId != existingOpenGroup.imageId) {
|
(
|
||||||
|
pollInfo.details != null &&
|
||||||
|
pollInfo.details.imageId != null && (
|
||||||
|
pollInfo.details.imageId != existingOpenGroup.imageId ||
|
||||||
|
!storage.hasDownloadedProfilePicture(dbGroupId)
|
||||||
|
)
|
||||||
|
) || (
|
||||||
|
pollInfo.details == null &&
|
||||||
|
existingOpenGroup.imageId != null &&
|
||||||
|
!storage.hasDownloadedProfilePicture(dbGroupId)
|
||||||
|
)
|
||||||
|
) {
|
||||||
JobQueue.shared.add(GroupAvatarDownloadJob(roomToken, server))
|
JobQueue.shared.add(GroupAvatarDownloadJob(roomToken, server))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user