feat: Update send icon to ArrowUp in TelegramCaptionBar and MultiImageEditorScreen
This commit is contained in:
@@ -7,6 +7,7 @@ import androidx.datastore.preferences.core.booleanPreferencesKey
|
||||
import androidx.datastore.preferences.core.edit
|
||||
import androidx.datastore.preferences.core.intPreferencesKey
|
||||
import androidx.datastore.preferences.core.stringPreferencesKey
|
||||
import androidx.datastore.preferences.core.stringSetPreferencesKey
|
||||
import androidx.datastore.preferences.preferencesDataStore
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
@@ -45,6 +46,9 @@ class PreferencesManager(private val context: Context) {
|
||||
|
||||
// Appearance / Customization
|
||||
val BACKGROUND_BLUR_COLOR_ID = stringPreferencesKey("background_blur_color_id") // id from BackgroundBlurPresets
|
||||
|
||||
// Pinned Chats (max 3)
|
||||
val PINNED_CHATS = stringSetPreferencesKey("pinned_chats") // Set of opponent public keys
|
||||
}
|
||||
|
||||
// ═════════════════════════════════════════════════════════════
|
||||
@@ -205,4 +209,33 @@ class PreferencesManager(private val context: Context) {
|
||||
suspend fun setBackgroundBlurColorId(value: String) {
|
||||
context.dataStore.edit { preferences -> preferences[BACKGROUND_BLUR_COLOR_ID] = value }
|
||||
}
|
||||
|
||||
// ═════════════════════════════════════════════════════════════
|
||||
// 📌 PINNED CHATS
|
||||
// ═════════════════════════════════════════════════════════════
|
||||
|
||||
val pinnedChats: Flow<Set<String>> =
|
||||
context.dataStore.data.map { preferences ->
|
||||
preferences[PINNED_CHATS] ?: emptySet()
|
||||
}
|
||||
|
||||
suspend fun setPinnedChats(value: Set<String>) {
|
||||
context.dataStore.edit { preferences -> preferences[PINNED_CHATS] = value }
|
||||
}
|
||||
|
||||
suspend fun togglePinChat(opponentKey: String): Boolean {
|
||||
var wasPinned = false
|
||||
context.dataStore.edit { preferences ->
|
||||
val current = preferences[PINNED_CHATS] ?: emptySet()
|
||||
if (current.contains(opponentKey)) {
|
||||
// Unpin
|
||||
preferences[PINNED_CHATS] = current - opponentKey
|
||||
wasPinned = true
|
||||
} else if (current.size < 3) {
|
||||
// Pin (max 3)
|
||||
preferences[PINNED_CHATS] = current + opponentKey
|
||||
}
|
||||
}
|
||||
return wasPinned
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user