mirror of
https://github.com/oxen-io/session-android.git
synced 2025-04-01 05:22:15 +00:00
Responded to PR comments
This commit is contained in:
parent
11c1fd382d
commit
7699e47f7b
@ -15,7 +15,7 @@ import java.util.concurrent.Executors
|
|||||||
|
|
||||||
object OpenGroupManager {
|
object OpenGroupManager {
|
||||||
private val executorService = Executors.newScheduledThreadPool(4)
|
private val executorService = Executors.newScheduledThreadPool(4)
|
||||||
private var pollers = mutableMapOf<String, OpenGroupPoller>() // One for each server
|
private val pollers = mutableMapOf<String, OpenGroupPoller>() // One for each server
|
||||||
private var isPolling = false
|
private var isPolling = false
|
||||||
private val pollUpdaterLock = Any()
|
private val pollUpdaterLock = Any()
|
||||||
|
|
||||||
@ -44,9 +44,7 @@ object OpenGroupManager {
|
|||||||
synchronized(pollUpdaterLock) {
|
synchronized(pollUpdaterLock) {
|
||||||
servers.forEach { server ->
|
servers.forEach { server ->
|
||||||
pollers[server]?.stop() // Shouldn't be necessary
|
pollers[server]?.stop() // Shouldn't be necessary
|
||||||
val poller = OpenGroupPoller(server, executorService)
|
pollers[server] = OpenGroupPoller(server, executorService).apply { startIfNeeded() }
|
||||||
poller.startIfNeeded()
|
|
||||||
pollers[server] = poller
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,24 +110,22 @@ object OpenGroupApi {
|
|||||||
val upload: Boolean = false,
|
val upload: Boolean = false,
|
||||||
val defaultUpload: Boolean = false,
|
val defaultUpload: Boolean = false,
|
||||||
) {
|
) {
|
||||||
fun toPollInfo(): RoomPollInfo {
|
fun toPollInfo() = RoomPollInfo(
|
||||||
return RoomPollInfo(
|
token = token,
|
||||||
token = token,
|
activeUsers = activeUsers,
|
||||||
activeUsers = activeUsers,
|
admin = admin,
|
||||||
admin = admin,
|
globalAdmin = globalAdmin,
|
||||||
globalAdmin = globalAdmin,
|
moderator = moderator,
|
||||||
moderator = moderator,
|
globalModerator = globalModerator,
|
||||||
globalModerator = globalModerator,
|
read = read,
|
||||||
read = read,
|
defaultRead = defaultRead,
|
||||||
defaultRead = defaultRead,
|
defaultAccessible = defaultAccessible,
|
||||||
defaultAccessible = defaultAccessible,
|
write = write,
|
||||||
write = write,
|
defaultWrite = defaultWrite,
|
||||||
defaultWrite = defaultWrite,
|
upload = upload,
|
||||||
upload = upload,
|
defaultUpload = defaultUpload,
|
||||||
defaultUpload = defaultUpload,
|
details = this
|
||||||
details = this
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy::class)
|
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy::class)
|
||||||
|
@ -40,7 +40,7 @@ class OpenGroupPoller(private val server: String, private val executorService: S
|
|||||||
var isCaughtUp = false
|
var isCaughtUp = false
|
||||||
var secondToLastJob: MessageReceiveJob? = null
|
var secondToLastJob: MessageReceiveJob? = null
|
||||||
private var future: ScheduledFuture<*>? = null
|
private var future: ScheduledFuture<*>? = null
|
||||||
private var runId: UUID = UUID.randomUUID()
|
@Volatile private var runId: UUID = UUID.randomUUID()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val pollInterval: Long = 4000L
|
private const val pollInterval: Long = 4000L
|
||||||
@ -59,16 +59,20 @@ class OpenGroupPoller(private val server: String, private val executorService: S
|
|||||||
|
|
||||||
// If we don't have an existing group and don't have a 'createGroupIfMissingWithPublicKey'
|
// If we don't have an existing group and don't have a 'createGroupIfMissingWithPublicKey'
|
||||||
// value then don't process the poll info
|
// value then don't process the poll info
|
||||||
val publicKey = ((existingOpenGroup?.publicKey ?: createGroupIfMissingWithPublicKey) ?: return)
|
val publicKey = existingOpenGroup?.publicKey ?: createGroupIfMissingWithPublicKey
|
||||||
|
val name = pollInfo.details?.name ?: existingOpenGroup?.name
|
||||||
|
val infoUpdates = pollInfo.details?.infoUpdates ?: existingOpenGroup?.infoUpdates
|
||||||
|
|
||||||
|
if (publicKey == null) return
|
||||||
|
|
||||||
val openGroup = OpenGroup(
|
val openGroup = OpenGroup(
|
||||||
server = server,
|
server = server,
|
||||||
room = pollInfo.token,
|
room = pollInfo.token,
|
||||||
name = ((pollInfo.details?.name ?: existingOpenGroup?.name) ?: ""),
|
name = name ?: "",
|
||||||
publicKey = publicKey,
|
publicKey = publicKey,
|
||||||
imageId = (pollInfo.details?.imageId ?: existingOpenGroup?.imageId),
|
imageId = (pollInfo.details?.imageId ?: existingOpenGroup?.imageId),
|
||||||
canWrite = pollInfo.write,
|
canWrite = pollInfo.write,
|
||||||
infoUpdates = ((pollInfo.details?.infoUpdates ?: existingOpenGroup?.infoUpdates) ?: 0)
|
infoUpdates = infoUpdates ?: 0
|
||||||
)
|
)
|
||||||
// - Open Group changes
|
// - Open Group changes
|
||||||
storage.updateOpenGroup(openGroup)
|
storage.updateOpenGroup(openGroup)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user