-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into tech/redux-pages
- Loading branch information
Showing
37 changed files
with
592 additions
and
324 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
domains/store/src/main/kotlin/app/dapk/st/domain/room/MutedRoomsStore.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package app.dapk.st.domain.room | ||
|
||
import app.dapk.db.DapkDb | ||
import app.dapk.st.core.CoroutineDispatchers | ||
import app.dapk.st.core.withIoContext | ||
import app.dapk.st.matrix.common.RoomId | ||
import app.dapk.st.matrix.sync.MuteableStore | ||
import com.squareup.sqldelight.runtime.coroutines.asFlow | ||
import com.squareup.sqldelight.runtime.coroutines.mapToList | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.MutableSharedFlow | ||
import kotlinx.coroutines.flow.firstOrNull | ||
import kotlinx.coroutines.flow.map | ||
|
||
internal class MutedStorePersistence( | ||
private val database: DapkDb, | ||
private val coroutineDispatchers: CoroutineDispatchers, | ||
) : MuteableStore { | ||
|
||
private val allMutedFlow = MutableSharedFlow<Set<RoomId>>(replay = 1) | ||
|
||
override suspend fun mute(roomId: RoomId) { | ||
coroutineDispatchers.withIoContext { | ||
database.mutedRoomQueries.insertMuted(roomId.value) | ||
} | ||
} | ||
|
||
override suspend fun unmute(roomId: RoomId) { | ||
coroutineDispatchers.withIoContext { | ||
database.mutedRoomQueries.removeMuted(roomId.value) | ||
} | ||
} | ||
|
||
override suspend fun isMuted(roomId: RoomId) = allMutedFlow.firstOrNull()?.contains(roomId) ?: false | ||
|
||
override fun observeMuted(): Flow<Set<RoomId>> = database.mutedRoomQueries.select() | ||
.asFlow() | ||
.mapToList() | ||
.map { it.map { RoomId(it) }.toSet() } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
domains/store/src/main/sqldelight/app/dapk/db/model/MutedRoom.sq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
CREATE TABLE IF NOT EXISTS dbMutedRoom ( | ||
room_id TEXT NOT NULL, | ||
PRIMARY KEY (room_id) | ||
); | ||
|
||
insertMuted: | ||
INSERT OR REPLACE INTO dbMutedRoom(room_id) | ||
VALUES (?); | ||
|
||
removeMuted: | ||
DELETE FROM dbMutedRoom | ||
WHERE room_id = ?; | ||
|
||
select: | ||
SELECT room_id | ||
FROM dbMutedRoom; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.