mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-25 02:55:23 +00:00
Using groupId as the key instead of the server alone
This commit is contained in:
parent
915c617364
commit
1f6a1b13b2
@ -117,15 +117,19 @@ class ConversationViewModel(
|
||||
communityWriteAccessJob?.cancel()
|
||||
communityWriteAccessJob = viewModelScope.launch {
|
||||
OpenGroupManager.getCommunitiesWriteAccessFlow()
|
||||
.map { it[openGroup?.server] }
|
||||
.map {
|
||||
if(openGroup?.groupId != null)
|
||||
it[openGroup?.groupId]
|
||||
else null
|
||||
}
|
||||
.filterNotNull()
|
||||
.collect{
|
||||
// update our community object
|
||||
_openGroup.updateTo(openGroup?.copy(canWrite = it))
|
||||
// when we get an update on the write access of a community
|
||||
// we need to update the input text accordingly
|
||||
_uiState.update {
|
||||
it.copy(hideInputBar = shouldHideInputBar())
|
||||
_uiState.update { state ->
|
||||
state.copy(hideInputBar = shouldHideInputBar())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -172,13 +172,12 @@ object OpenGroupManager {
|
||||
|
||||
fun updateOpenGroup(openGroup: OpenGroup, context: Context) {
|
||||
val threadDB = DatabaseComponent.get(context).lokiThreadDatabase()
|
||||
val openGroupID = "${openGroup.server}.${openGroup.room}"
|
||||
val threadID = GroupManager.getOpenGroupThreadID(openGroupID, context)
|
||||
val threadID = GroupManager.getOpenGroupThreadID(openGroup.groupId, context)
|
||||
threadDB.setOpenGroupChat(openGroup, threadID)
|
||||
|
||||
// update write access for this community
|
||||
val writeAccesses = _communityWriteAccess.value.toMutableMap()
|
||||
writeAccesses[openGroup.server] = openGroup.canWrite
|
||||
writeAccesses[openGroup.groupId] = openGroup.canWrite
|
||||
_communityWriteAccess.value = writeAccesses
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user