-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use key composable to separate conv detail screens. Automatically remember last typed text in persistent storage. * Update comments.
- Loading branch information
Showing
23 changed files
with
305 additions
and
95 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
19 changes: 19 additions & 0 deletions
19
.../artemis/native_app/feature/metis/conversation/service/storage/ReplyTextStorageService.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,19 @@ | ||
package de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.service.storage | ||
|
||
internal interface ReplyTextStorageService { | ||
|
||
suspend fun getStoredReplyText( | ||
serverHost: String, | ||
courseId: Long, | ||
conversationId: Long, | ||
postId: Long? | ||
): String | ||
|
||
suspend fun updateStoredReplyText( | ||
serverHost: String, | ||
courseId: Long, | ||
conversationId: Long, | ||
postId: Long?, | ||
text: String | ||
) | ||
} |
51 changes: 51 additions & 0 deletions
51
...native_app/feature/metis/conversation/service/storage/impl/ReplyTextStorageServiceImpl.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,51 @@ | ||
package de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.service.storage.impl | ||
|
||
import android.content.Context | ||
import androidx.datastore.preferences.core.Preferences | ||
import androidx.datastore.preferences.core.edit | ||
import androidx.datastore.preferences.core.stringPreferencesKey | ||
import androidx.datastore.preferences.preferencesDataStore | ||
import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.service.storage.ReplyTextStorageService | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.first | ||
import kotlinx.coroutines.flow.map | ||
|
||
internal class ReplyTextStorageServiceImpl(private val context: Context) : ReplyTextStorageService { | ||
|
||
private companion object { | ||
private const val DATA_STORE_NAME = "ReplyTextStorage" | ||
} | ||
|
||
private val Context.dataStore by preferencesDataStore(DATA_STORE_NAME) | ||
|
||
override suspend fun getStoredReplyText( | ||
serverHost: String, | ||
courseId: Long, | ||
conversationId: Long, | ||
postId: Long? | ||
): String = context | ||
.dataStore | ||
.data | ||
.map { it[getKey(serverHost, courseId, conversationId, postId)].orEmpty() } | ||
.first() | ||
|
||
override suspend fun updateStoredReplyText( | ||
serverHost: String, | ||
courseId: Long, | ||
conversationId: Long, | ||
postId: Long?, | ||
text: String | ||
) { | ||
context.dataStore.edit { data -> | ||
data[getKey(serverHost, courseId, conversationId, postId)] = text | ||
} | ||
} | ||
|
||
private fun getKey( | ||
serverHost: String, | ||
courseId: Long, | ||
conversationId: Long, | ||
postId: Long? | ||
): Preferences.Key<String> = | ||
stringPreferencesKey("$serverHost|$courseId|$conversationId|$postId") | ||
} |
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
10 changes: 10 additions & 0 deletions
10
...s/www1/artemis/native_app/feature/metis/conversation/ui/reply/InitialReplyTextProvider.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,10 @@ | ||
package de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.reply | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface InitialReplyTextProvider { | ||
|
||
val newMessageText: Flow<String> | ||
|
||
fun updateInitialReplyText(text: String) | ||
} |
Oops, something went wrong.