mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-08 15:28:42 +01:00
feat: community-specific sort type (#586)
This commit is contained in:
parent
bb4492e851
commit
843b4098ca
@ -29,4 +29,5 @@ sealed class OptionId(val value: Int) {
|
||||
data object Favorite : OptionId(21)
|
||||
data object ViewModlog : OptionId(22)
|
||||
data object Unban : OptionId(23)
|
||||
}
|
||||
data object SetCustomSort : OptionId(24)
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.toIcon
|
||||
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.toReadableName
|
||||
|
||||
class ListingTypeBottomSheet(
|
||||
private val sheetKey: String,
|
||||
private val isLogged: Boolean = false,
|
||||
) : Screen {
|
||||
@Composable
|
||||
@ -89,7 +88,6 @@ class ListingTypeBottomSheet(
|
||||
notificationCenter.send(
|
||||
NotificationCenterEvent.ChangeFeedType(
|
||||
value = value,
|
||||
key = sheetKey,
|
||||
)
|
||||
)
|
||||
navigationCoordinator.hideBottomSheet()
|
||||
|
@ -42,9 +42,9 @@ import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.toReadableName
|
||||
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.toSortType
|
||||
|
||||
class SortBottomSheet(
|
||||
private val sheetKey: String,
|
||||
private val comments: Boolean,
|
||||
private val values: List<Int>,
|
||||
private val comments: Boolean = false,
|
||||
private val defaultForCommunity: Boolean = false,
|
||||
private val expandTop: Boolean = false,
|
||||
) : Screen {
|
||||
@Composable
|
||||
@ -68,7 +68,7 @@ class SortBottomSheet(
|
||||
values = values,
|
||||
expandTop = expandTop,
|
||||
comments = comments,
|
||||
sheetKey = sheetKey,
|
||||
defaultForCommunity = defaultForCommunity,
|
||||
)
|
||||
)
|
||||
}
|
||||
@ -76,10 +76,10 @@ class SortBottomSheet(
|
||||
}
|
||||
|
||||
internal class SortBottomSheetMain(
|
||||
private val sheetKey: String,
|
||||
private val comments: Boolean,
|
||||
private val values: List<Int>,
|
||||
private val expandTop: Boolean = false,
|
||||
private val defaultForCommunity: Boolean = false,
|
||||
) : Screen {
|
||||
@Composable
|
||||
override fun Content() {
|
||||
@ -118,19 +118,18 @@ internal class SortBottomSheetMain(
|
||||
navigator.push(
|
||||
SortBottomSheetTop(
|
||||
comments = comments,
|
||||
sheetKey = sheetKey,
|
||||
defaultForCommunity = defaultForCommunity,
|
||||
)
|
||||
)
|
||||
} else {
|
||||
val event = if (comments) {
|
||||
NotificationCenterEvent.ChangeCommentSortType(
|
||||
value = sortValue,
|
||||
key = sheetKey,
|
||||
)
|
||||
} else {
|
||||
NotificationCenterEvent.ChangeSortType(
|
||||
value = sortValue,
|
||||
key = sheetKey,
|
||||
defaultForCommunity = defaultForCommunity,
|
||||
)
|
||||
}
|
||||
notificationCenter.send(event)
|
||||
@ -167,7 +166,6 @@ internal class SortBottomSheetMain(
|
||||
}
|
||||
|
||||
internal class SortBottomSheetTop(
|
||||
private val sheetKey: String,
|
||||
private val comments: Boolean,
|
||||
private val values: List<Int> = listOf(
|
||||
SortType.Top.PastHour,
|
||||
@ -178,6 +176,7 @@ internal class SortBottomSheetTop(
|
||||
SortType.Top.Month,
|
||||
SortType.Top.Year,
|
||||
).map { it.toInt() },
|
||||
private val defaultForCommunity: Boolean = false,
|
||||
) : Screen {
|
||||
@Composable
|
||||
override fun Content() {
|
||||
@ -229,12 +228,11 @@ internal class SortBottomSheetTop(
|
||||
val event = if (comments) {
|
||||
NotificationCenterEvent.ChangeCommentSortType(
|
||||
value = sortValue,
|
||||
key = sheetKey,
|
||||
)
|
||||
} else {
|
||||
NotificationCenterEvent.ChangeSortType(
|
||||
value = sortValue,
|
||||
key = sheetKey,
|
||||
defaultForCommunity = defaultForCommunity,
|
||||
)
|
||||
}
|
||||
notificationCenter.send(event)
|
||||
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">القراءة والمحتويات</string>
|
||||
<string name="settings_title_pictures">الصور</string>
|
||||
<string name="settings_title_experimental">التجارب</string>
|
||||
<string name="community_set_custom_sort">نوع الفرز المخصص</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Четене и съдържание</string>
|
||||
<string name="settings_title_pictures">Снимки</string>
|
||||
<string name="settings_title_experimental">Експерименти</string>
|
||||
<string name="community_set_custom_sort">Персонализиран тип сортиране</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Čtení a obsah</string>
|
||||
<string name="settings_title_pictures">obrázky</string>
|
||||
<string name="settings_title_experimental">Experimenty</string>
|
||||
<string name="community_set_custom_sort">Vlastní typ řazení</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Læsning og indhold</string>
|
||||
<string name="settings_title_pictures">Billeder</string>
|
||||
<string name="settings_title_experimental">Eksperimenter</string>
|
||||
<string name="community_set_custom_sort">Brugerdefineret sorteringstype</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Lektüre und Inhalt</string>
|
||||
<string name="settings_title_pictures">Bilder</string>
|
||||
<string name="settings_title_experimental">Experimente</string>
|
||||
<string name="community_set_custom_sort">Benutzerdefinierter Sortiertyp</string>
|
||||
</resources>
|
||||
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Ανάγνωση και περιεχόμενο</string>
|
||||
<string name="settings_title_pictures">Εικόνες</string>
|
||||
<string name="settings_title_experimental">Πειράματα</string>
|
||||
<string name="community_set_custom_sort">Προσαρμοσμένος τύπος ταξινόμησης</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Legado kaj enhavo</string>
|
||||
<string name="settings_title_pictures">Bildoj</string>
|
||||
<string name="settings_title_experimental">Eksperimentoj</string>
|
||||
<string name="community_set_custom_sort">Propra ordiga tipo</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Lectura y contenidos</string>
|
||||
<string name="settings_title_pictures">Fotos</string>
|
||||
<string name="settings_title_experimental">Experimentos</string>
|
||||
<string name="community_set_custom_sort">Tipo de orden personalizado</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Lugemine ja sisu</string>
|
||||
<string name="settings_title_pictures">Pildid</string>
|
||||
<string name="settings_title_experimental">Eksperimendid</string>
|
||||
<string name="community_set_custom_sort">Kohandatud sortimise tüüp</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Lukeminen ja sisältö</string>
|
||||
<string name="settings_title_pictures">Kuvia</string>
|
||||
<string name="settings_title_experimental">Kokeilut</string>
|
||||
<string name="community_set_custom_sort">Mukautettu lajittelutyyppi</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Lecture et contenu</string>
|
||||
<string name="settings_title_pictures">Des photos</string>
|
||||
<string name="settings_title_experimental">Expériences</string>
|
||||
<string name="community_set_custom_sort">Type de tri personnalisé</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Léamh agus ábhar</string>
|
||||
<string name="settings_title_pictures">Pictiúirí</string>
|
||||
<string name="settings_title_experimental">Turgnaimh</string>
|
||||
<string name="community_set_custom_sort">Cineál sórtála saincheaptha</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Čitanje i sadržaj</string>
|
||||
<string name="settings_title_pictures">Slike</string>
|
||||
<string name="settings_title_experimental">Eksperimenti</string>
|
||||
<string name="community_set_custom_sort">Vrsta prilagođenog sortiranja</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Olvasás és tartalom</string>
|
||||
<string name="settings_title_pictures">Képek</string>
|
||||
<string name="settings_title_experimental">Kísérletek</string>
|
||||
<string name="community_set_custom_sort">Egyedi rendezési típus</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Lettura e contenuti</string>
|
||||
<string name="settings_title_pictures">Immagini</string>
|
||||
<string name="settings_title_experimental">Esperimenti</string>
|
||||
<string name="community_set_custom_sort">Tipo di ordinamento personalizzato</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Skaitymas ir turinys</string>
|
||||
<string name="settings_title_pictures">Paveikslėliai</string>
|
||||
<string name="settings_title_experimental">Eksperimentai</string>
|
||||
<string name="community_set_custom_sort">Pasirinktinis rūšiavimo tipas</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Lasīšana un saturs</string>
|
||||
<string name="settings_title_pictures">Bildes</string>
|
||||
<string name="settings_title_experimental">Eksperimenti</string>
|
||||
<string name="community_set_custom_sort">Pielāgots kārtošanas veids</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Qari u kontenut</string>
|
||||
<string name="settings_title_pictures">Stampi</string>
|
||||
<string name="settings_title_experimental">Esperimenti</string>
|
||||
<string name="community_set_custom_sort">Tip ta \'xorta tad-dwana</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Lezen en inhoud</string>
|
||||
<string name="settings_title_pictures">Afbeeldingen</string>
|
||||
<string name="settings_title_experimental">Experimenten</string>
|
||||
<string name="community_set_custom_sort">Aangepast sorteertype</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Lesing og innhold</string>
|
||||
<string name="settings_title_pictures">Bilder</string>
|
||||
<string name="settings_title_experimental">Eksperimenter</string>
|
||||
<string name="community_set_custom_sort">Egendefinert sorteringstype</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Lektura i treść</string>
|
||||
<string name="settings_title_pictures">Kino</string>
|
||||
<string name="settings_title_experimental">Eksperymenty</string>
|
||||
<string name="community_set_custom_sort">Niestandardowy typ sortowania</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Leitura e conteúdos</string>
|
||||
<string name="settings_title_pictures">Fotos</string>
|
||||
<string name="settings_title_experimental">Experimentos</string>
|
||||
<string name="community_set_custom_sort">Tipo de ordem personalizado</string>
|
||||
</resources>
|
||||
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Leitura e conteúdos</string>
|
||||
<string name="settings_title_pictures">Fotos</string>
|
||||
<string name="settings_title_experimental">Experimentos</string>
|
||||
<string name="community_set_custom_sort">Tipo de ordem personalizado</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Lectură și conținut</string>
|
||||
<string name="settings_title_pictures">Imagini</string>
|
||||
<string name="settings_title_experimental">Experimente</string>
|
||||
<string name="community_set_custom_sort">Tip de sortare personalizat</string>
|
||||
</resources>
|
@ -345,4 +345,5 @@
|
||||
<string name="settings_title_reading">Чтение и содержание</string>
|
||||
<string name="settings_title_pictures">Картинки</string>
|
||||
<string name="settings_title_experimental">Эксперименты</string>
|
||||
<string name="community_set_custom_sort">Пользовательский тип сортировки</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Läsning och innehåll</string>
|
||||
<string name="settings_title_pictures">Bilder</string>
|
||||
<string name="settings_title_experimental">Experiment</string>
|
||||
<string name="community_set_custom_sort">Anpassad sorteringstyp</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Čítanie a obsah</string>
|
||||
<string name="settings_title_pictures">Obrázky</string>
|
||||
<string name="settings_title_experimental">Experimenty</string>
|
||||
<string name="community_set_custom_sort">Vlastný typ triedenia</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Branje in vsebina</string>
|
||||
<string name="settings_title_pictures">Slike</string>
|
||||
<string name="settings_title_experimental">Eksperimenti</string>
|
||||
<string name="community_set_custom_sort">Vrsta razvrščanja po meri</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Leximi dhe përmbajtja</string>
|
||||
<string name="settings_title_pictures">Fotot</string>
|
||||
<string name="settings_title_experimental">Eksperimentet</string>
|
||||
<string name="community_set_custom_sort">Lloji i personalizuar i renditjes</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">lipu</string>
|
||||
<string name="settings_title_pictures">sitelen</string>
|
||||
<string name="settings_title_experimental">lukin</string>
|
||||
<string name="community_set_custom_sort">nanpa pi kulupu ni</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Okuma ve içindekiler</string>
|
||||
<string name="settings_title_pictures">Resimler</string>
|
||||
<string name="settings_title_experimental">Deneyler</string>
|
||||
<string name="community_set_custom_sort">Özel sıralama türü</string>
|
||||
</resources>
|
@ -345,4 +345,5 @@
|
||||
<string name="settings_title_reading">Читання та зміст</string>
|
||||
<string name="settings_title_pictures">Картинки</string>
|
||||
<string name="settings_title_experimental">Експерименти</string>
|
||||
<string name="community_set_custom_sort">Спеціальний тип сортування</string>
|
||||
</resources>
|
@ -346,4 +346,5 @@
|
||||
<string name="settings_title_reading">Reading and contents</string>
|
||||
<string name="settings_title_pictures">Pictures</string>
|
||||
<string name="settings_title_experimental">Experiments</string>
|
||||
<string name="community_set_custom_sort">Set custom sort type</string>
|
||||
</resources>
|
@ -21,13 +21,13 @@ import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.UserModel
|
||||
import kotlin.time.Duration
|
||||
|
||||
sealed interface NotificationCenterEvent {
|
||||
data class ChangeSortType(val value: SortType, val key: String? = null) :
|
||||
data class ChangeSortType(val value: SortType, val defaultForCommunity: Boolean) :
|
||||
NotificationCenterEvent
|
||||
|
||||
data class ChangeCommentSortType(val value: SortType, val key: String? = null) :
|
||||
data class ChangeCommentSortType(val value: SortType) :
|
||||
NotificationCenterEvent
|
||||
|
||||
data class ChangeFeedType(val value: ListingType, val key: String? = null) :
|
||||
data class ChangeFeedType(val value: ListingType) :
|
||||
NotificationCenterEvent
|
||||
|
||||
data class ChangeInboxType(val unreadOnly: Boolean) : NotificationCenterEvent
|
||||
|
@ -6,6 +6,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.persistence.DefaultDriverFa
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.DriverFactory
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.AccountRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.SettingsRepository
|
||||
import org.koin.core.qualifier.named
|
||||
import org.koin.dsl.module
|
||||
import org.koin.java.KoinJavaComponent
|
||||
|
||||
@ -18,7 +19,7 @@ actual val persistenceInnerModule = module {
|
||||
}
|
||||
single<DatabaseKeyProvider> {
|
||||
DefaultDatabaseKeyProvider(
|
||||
keyStore = get(),
|
||||
keyStore = get(named("default")),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,9 @@ package com.github.diegoberaldin.raccoonforlemmy.core.persistence.di
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.DatabaseProvider
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.DefaultDatabaseProvider
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.AccountRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.CommunitySortRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.DefaultAccountRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.DefaultCommunitySortRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.DefaultDraftRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.DefaultFavoriteCommunityRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.DefaultInstanceSelectionRepository
|
||||
@ -14,6 +16,8 @@ import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.Favo
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.InstanceSelectionRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.MultiCommunityRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.SettingsRepository
|
||||
import org.koin.core.parameter.parametersOf
|
||||
import org.koin.core.qualifier.named
|
||||
import org.koin.dsl.module
|
||||
|
||||
val corePersistenceModule = module {
|
||||
@ -31,7 +35,7 @@ val corePersistenceModule = module {
|
||||
single<SettingsRepository> {
|
||||
DefaultSettingsRepository(
|
||||
provider = get(),
|
||||
keyStore = get(),
|
||||
keyStore = get(named("default")),
|
||||
)
|
||||
}
|
||||
single<MultiCommunityRepository> {
|
||||
@ -46,7 +50,7 @@ val corePersistenceModule = module {
|
||||
}
|
||||
single<InstanceSelectionRepository> {
|
||||
DefaultInstanceSelectionRepository(
|
||||
keyStore = get(),
|
||||
keyStore = get(named("default")),
|
||||
)
|
||||
}
|
||||
single<DraftRepository> {
|
||||
@ -54,4 +58,9 @@ val corePersistenceModule = module {
|
||||
provider = get(),
|
||||
)
|
||||
}
|
||||
single<CommunitySortRepository> {
|
||||
DefaultCommunitySortRepository(
|
||||
keyStore = get(named("custom"), parameters = { parametersOf("communitySort") })
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
package com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository
|
||||
|
||||
interface CommunitySortRepository {
|
||||
fun getSort(handle: String): Int?
|
||||
|
||||
fun saveSort(handle: String, value: Int)
|
||||
|
||||
fun clear()
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository
|
||||
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.preferences.TemporaryKeyStore
|
||||
|
||||
internal class DefaultCommunitySortRepository(
|
||||
private val keyStore: TemporaryKeyStore
|
||||
) : CommunitySortRepository {
|
||||
|
||||
override fun getSort(handle: String): Int? = keyStore[handle, -1].takeIf { it > 0 }
|
||||
|
||||
override fun saveSort(handle: String, value: Int) {
|
||||
keyStore.save(handle, value)
|
||||
}
|
||||
|
||||
override fun clear() {
|
||||
keyStore.removeAll()
|
||||
}
|
||||
}
|
@ -8,24 +8,36 @@ import com.github.diegoberaldin.raccoonforlemmy.core.preferences.DefaultTemporar
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.preferences.TemporaryKeyStore
|
||||
import com.russhwolf.settings.Settings
|
||||
import com.russhwolf.settings.SharedPreferencesSettings
|
||||
import org.koin.core.module.dsl.singleOf
|
||||
import org.koin.core.parameter.parametersOf
|
||||
import org.koin.core.qualifier.named
|
||||
import org.koin.dsl.module
|
||||
|
||||
actual val corePreferencesModule = module {
|
||||
singleOf(::SharedPreferencesProvider)
|
||||
single<Settings> {
|
||||
val sharedPreferencesProvider: SharedPreferencesProvider by inject()
|
||||
SharedPreferencesSettings(
|
||||
sharedPreferencesProvider.sharedPreferences,
|
||||
false,
|
||||
single { params ->
|
||||
SharedPreferencesProvider(
|
||||
name = params[0],
|
||||
context = get(),
|
||||
)
|
||||
}
|
||||
single<TemporaryKeyStore> {
|
||||
DefaultTemporaryKeyStore(settings = get())
|
||||
single<Settings> { params ->
|
||||
val sharedPreferencesProvider: SharedPreferencesProvider = get(parameters = {
|
||||
parametersOf(params[0])
|
||||
})
|
||||
SharedPreferencesSettings(
|
||||
delegate = sharedPreferencesProvider.sharedPreferences,
|
||||
commit = false,
|
||||
)
|
||||
}
|
||||
single<TemporaryKeyStore>(named("default")) {
|
||||
DefaultTemporaryKeyStore(settings = get(parameters = { parametersOf(null) }))
|
||||
}
|
||||
factory<TemporaryKeyStore>(named("custom")) { params ->
|
||||
DefaultTemporaryKeyStore(settings = get(parameters = { parametersOf(params[0]) }))
|
||||
}
|
||||
}
|
||||
|
||||
private class SharedPreferencesProvider(
|
||||
name: String? = null,
|
||||
context: Context,
|
||||
) {
|
||||
|
||||
@ -36,7 +48,7 @@ private class SharedPreferencesProvider(
|
||||
private val masterKeyAlias: String = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC)
|
||||
|
||||
val sharedPreferences: SharedPreferences = EncryptedSharedPreferences.create(
|
||||
PREFERENCES_NAME,
|
||||
name ?: PREFERENCES_NAME,
|
||||
masterKeyAlias,
|
||||
context,
|
||||
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
||||
|
@ -1,9 +1,14 @@
|
||||
package com.github.diegoberaldin.raccoonforlemmy.core.preferences.di
|
||||
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.preferences.TemporaryKeyStore
|
||||
import org.koin.core.parameter.parametersOf
|
||||
import org.koin.core.qualifier.named
|
||||
import org.koin.java.KoinJavaComponent
|
||||
|
||||
actual fun getTemporaryKeyStore(): TemporaryKeyStore {
|
||||
val res by KoinJavaComponent.inject<TemporaryKeyStore>(TemporaryKeyStore::class.java)
|
||||
actual fun getTemporaryKeyStore(name: String): TemporaryKeyStore {
|
||||
val res by KoinJavaComponent.inject<TemporaryKeyStore>(
|
||||
clazz = TemporaryKeyStore::class.java,
|
||||
qualifier = named("custom"),
|
||||
parameters = { parametersOf(name) })
|
||||
return res
|
||||
}
|
||||
|
@ -61,4 +61,8 @@ internal class DefaultTemporaryKeyStore(
|
||||
override fun remove(key: String) {
|
||||
settings.remove(key)
|
||||
}
|
||||
|
||||
override fun removeAll() {
|
||||
settings.clear()
|
||||
}
|
||||
}
|
||||
|
@ -119,6 +119,11 @@ interface TemporaryKeyStore {
|
||||
*/
|
||||
fun remove(key: String)
|
||||
|
||||
/**
|
||||
* Removes all entries from the store.
|
||||
*/
|
||||
fun removeAll()
|
||||
|
||||
/**
|
||||
* Retrieve a string list given its key.
|
||||
*/
|
||||
|
@ -2,4 +2,4 @@ package com.github.diegoberaldin.raccoonforlemmy.core.preferences.di
|
||||
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.preferences.TemporaryKeyStore
|
||||
|
||||
expect fun getTemporaryKeyStore(): TemporaryKeyStore
|
||||
expect fun getTemporaryKeyStore(name: String): TemporaryKeyStore
|
||||
|
@ -2,21 +2,41 @@ package com.github.diegoberaldin.raccoonforlemmy.core.preferences.di
|
||||
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.preferences.DefaultTemporaryKeyStore
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.preferences.TemporaryKeyStore
|
||||
import com.russhwolf.settings.ExperimentalSettingsImplementation
|
||||
import com.russhwolf.settings.KeychainSettings
|
||||
import com.russhwolf.settings.Settings
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
import org.koin.core.parameter.parametersOf
|
||||
import org.koin.core.qualifier.named
|
||||
import org.koin.dsl.module
|
||||
|
||||
private const val DEFAULT_NAME = "secret_shared_prefs"
|
||||
|
||||
actual val corePreferencesModule = module {
|
||||
single<Settings> {
|
||||
KeychainSettings(service = "secret_shared_prefs")
|
||||
single<Settings> { params ->
|
||||
val name: String? = params[0]
|
||||
@OptIn(ExperimentalSettingsImplementation::class)
|
||||
KeychainSettings(service = name ?: DEFAULT_NAME)
|
||||
}
|
||||
single<TemporaryKeyStore> {
|
||||
DefaultTemporaryKeyStore(settings = get())
|
||||
single<TemporaryKeyStore>(named("default")) {
|
||||
DefaultTemporaryKeyStore(settings = get(parameters = { parametersOf(null) }))
|
||||
}
|
||||
factory<TemporaryKeyStore>(named("custom")) { params ->
|
||||
DefaultTemporaryKeyStore(settings = get(parameters = { parametersOf(params[0]) }))
|
||||
}
|
||||
}
|
||||
|
||||
object TemporaryKeyStoreHelper : KoinComponent {
|
||||
val temporaryKeyStore: TemporaryKeyStore by inject()
|
||||
internal object TemporaryKeyStoreHelper : KoinComponent {
|
||||
val temporaryKeyStore: TemporaryKeyStore by inject(named("default"))
|
||||
|
||||
fun getTemporaryKeyStore(name: String): TemporaryKeyStore {
|
||||
val temporaryKeyStore: TemporaryKeyStore by inject(
|
||||
qualifier = named("custom"),
|
||||
parameters = {
|
||||
parametersOf(name)
|
||||
},
|
||||
)
|
||||
return temporaryKeyStore
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,6 @@ package com.github.diegoberaldin.raccoonforlemmy.core.preferences.di
|
||||
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.preferences.TemporaryKeyStore
|
||||
|
||||
actual fun getTemporaryKeyStore(): TemporaryKeyStore {
|
||||
return TemporaryKeyStoreHelper.temporaryKeyStore
|
||||
actual fun getTemporaryKeyStore(name: String): TemporaryKeyStore {
|
||||
return TemporaryKeyStoreHelper.getTemporaryKeyStore(name)
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ val coreIdentityModule = module {
|
||||
single<ApiConfigurationRepository> {
|
||||
DefaultApiConfigurationRepository(
|
||||
serviceProvider = get(named("default")),
|
||||
keyStore = get(),
|
||||
keyStore = get(named("default")),
|
||||
)
|
||||
}
|
||||
single<IdentityRepository> {
|
||||
@ -44,6 +44,7 @@ val coreIdentityModule = module {
|
||||
accountRepository = get(),
|
||||
settingsRepository = get(),
|
||||
siteRepository = get(),
|
||||
communitySortRepository = get(),
|
||||
)
|
||||
}
|
||||
single<LogoutUseCase> {
|
||||
@ -53,6 +54,7 @@ val coreIdentityModule = module {
|
||||
notificationCenter = get(),
|
||||
settingsRepository = get(),
|
||||
contentResetCoordinator = get(),
|
||||
communitySortRepository = get(),
|
||||
)
|
||||
}
|
||||
single<SwitchAccountUseCase> {
|
||||
@ -62,6 +64,7 @@ val coreIdentityModule = module {
|
||||
settingsRepository = get(),
|
||||
serviceProvider = get(named("default")),
|
||||
notificationCenter = get(),
|
||||
communitySortRepository = get(),
|
||||
)
|
||||
}
|
||||
single<DeleteAccountUseCase> {
|
||||
|
@ -2,6 +2,7 @@ package com.github.diegoberaldin.raccoonforlemmy.domain.identity.usecase
|
||||
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.data.AccountModel
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.AccountRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.CommunitySortRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.SettingsRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.utils.debug.logDebug
|
||||
import com.github.diegoberaldin.raccoonforlemmy.domain.identity.repository.ApiConfigurationRepository
|
||||
@ -16,6 +17,7 @@ internal class DefaultLoginUseCase(
|
||||
private val accountRepository: AccountRepository,
|
||||
private val settingsRepository: SettingsRepository,
|
||||
private val siteRepository: SiteRepository,
|
||||
private val communitySortRepository: CommunitySortRepository,
|
||||
) : LoginUseCase {
|
||||
|
||||
override suspend operator fun invoke(
|
||||
@ -72,6 +74,7 @@ internal class DefaultLoginUseCase(
|
||||
|
||||
val newSettings = settingsRepository.getSettings(id)
|
||||
settingsRepository.changeCurrentSettings(newSettings)
|
||||
communitySortRepository.clear()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.notifications.ContentResetC
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.notifications.NotificationCenter
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.notifications.NotificationCenterEvent
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.AccountRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.CommunitySortRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.SettingsRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.domain.identity.repository.IdentityRepository
|
||||
|
||||
@ -13,12 +14,14 @@ internal class DefaultLogoutUseCase(
|
||||
private val notificationCenter: NotificationCenter,
|
||||
private val settingsRepository: SettingsRepository,
|
||||
private val contentResetCoordinator: ContentResetCoordinator,
|
||||
private val communitySortRepository: CommunitySortRepository,
|
||||
) : LogoutUseCase {
|
||||
override suspend operator fun invoke() {
|
||||
contentResetCoordinator.resetHome = true
|
||||
contentResetCoordinator.resetExplore = true
|
||||
|
||||
identityRepository.clearToken()
|
||||
communitySortRepository.clear()
|
||||
notificationCenter.send(NotificationCenterEvent.Logout)
|
||||
|
||||
val oldAccountId = accountRepository.getActive()?.id
|
||||
|
@ -5,6 +5,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.notifications.NotificationC
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.notifications.NotificationCenterEvent
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.data.AccountModel
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.AccountRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.CommunitySortRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.SettingsRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.domain.identity.repository.IdentityRepository
|
||||
|
||||
@ -14,6 +15,7 @@ internal class DefaultSwitchAccountUseCase(
|
||||
private val serviceProvider: ServiceProvider,
|
||||
private val notificationCenter: NotificationCenter,
|
||||
private val settingsRepository: SettingsRepository,
|
||||
private val communitySortRepository: CommunitySortRepository,
|
||||
) : SwitchAccountUseCase {
|
||||
override suspend fun invoke(account: AccountModel) {
|
||||
val accountId = account.id ?: return
|
||||
@ -26,6 +28,7 @@ internal class DefaultSwitchAccountUseCase(
|
||||
}
|
||||
accountRepository.setActive(accountId, true)
|
||||
notificationCenter.send(NotificationCenterEvent.Logout)
|
||||
communitySortRepository.clear()
|
||||
serviceProvider.changeInstance(instance)
|
||||
identityRepository.storeToken(jwt)
|
||||
identityRepository.refreshLoggedState()
|
||||
|
@ -169,7 +169,6 @@ class ExploreScreen : Screen {
|
||||
onSelectListingType = rememberCallback {
|
||||
focusManager.clearFocus()
|
||||
val sheet = ListingTypeBottomSheet(
|
||||
sheetKey = key,
|
||||
isLogged = uiState.isLogged,
|
||||
)
|
||||
navigationCoordinator.showBottomSheet(sheet)
|
||||
@ -177,9 +176,7 @@ class ExploreScreen : Screen {
|
||||
onSelectSortType = rememberCallback {
|
||||
focusManager.clearFocus()
|
||||
val sheet = SortBottomSheet(
|
||||
sheetKey = key,
|
||||
values = uiState.availableSortTypes.map { it.toInt() },
|
||||
comments = false,
|
||||
expandTop = true,
|
||||
)
|
||||
navigationCoordinator.showBottomSheet(sheet)
|
||||
|
@ -206,7 +206,6 @@ class SettingsScreen : Screen {
|
||||
value = uiState.defaultListingType.toReadableName(),
|
||||
onTap = rememberCallback {
|
||||
val sheet = ListingTypeBottomSheet(
|
||||
sheetKey = key,
|
||||
isLogged = uiState.isLogged,
|
||||
)
|
||||
navigationCoordinator.showBottomSheet(sheet)
|
||||
@ -219,10 +218,8 @@ class SettingsScreen : Screen {
|
||||
value = uiState.defaultPostSortType.toReadableName(),
|
||||
onTap = rememberCallback {
|
||||
val sheet = SortBottomSheet(
|
||||
sheetKey = key,
|
||||
values = uiState.availableSortTypesForPosts.map { it.toInt() },
|
||||
expandTop = true,
|
||||
comments = false,
|
||||
)
|
||||
navigationCoordinator.showBottomSheet(sheet)
|
||||
},
|
||||
@ -234,7 +231,6 @@ class SettingsScreen : Screen {
|
||||
value = uiState.defaultCommentSortType.toReadableName(),
|
||||
onTap = rememberCallback {
|
||||
val sheet = SortBottomSheet(
|
||||
sheetKey = key,
|
||||
comments = true,
|
||||
values = uiState.availableSortTypesForComments.map { it.toInt() },
|
||||
)
|
||||
|
@ -11,4 +11,6 @@ kotlin.mpp.androidSourceSetLayoutVersion=2
|
||||
#Compose
|
||||
org.jetbrains.compose.experimental.uikit.enabled=true
|
||||
#Native
|
||||
kotlin.native.ignoreDisabledTargets=true
|
||||
kotlin.native.ignoreDisabledTargets=true
|
||||
# AGP
|
||||
kotlin.mpp.androidGradlePluginCompatibility.nowarn=true
|
@ -305,7 +305,6 @@ class AccountSettingsScreen : Screen {
|
||||
value = uiState.defaultListingType.toReadableName(),
|
||||
onTap = rememberCallback {
|
||||
val sheet = ListingTypeBottomSheet(
|
||||
sheetKey = key,
|
||||
isLogged = true,
|
||||
)
|
||||
navigationCoordinator.showBottomSheet(sheet)
|
||||
@ -318,10 +317,8 @@ class AccountSettingsScreen : Screen {
|
||||
value = uiState.defaultSortType.toReadableName(),
|
||||
onTap = rememberCallback {
|
||||
val sheet = SortBottomSheet(
|
||||
sheetKey = key,
|
||||
values = uiState.availableSortTypes.map { it.toInt() },
|
||||
expandTop = true,
|
||||
comments = false,
|
||||
)
|
||||
navigationCoordinator.showBottomSheet(sheet)
|
||||
},
|
||||
|
@ -19,7 +19,6 @@ interface CommunityDetailMviModel :
|
||||
sealed interface Intent {
|
||||
data object Refresh : Intent
|
||||
data object LoadNextPage : Intent
|
||||
data class ChangeSort(val value: SortType) : Intent
|
||||
data class UpVotePost(val id: Int, val feedback: Boolean = false) : Intent
|
||||
data class DownVotePost(val id: Int, val feedback: Boolean = false) : Intent
|
||||
data class SavePost(val id: Int, val feedback: Boolean = false) : Intent
|
||||
|
@ -271,9 +271,7 @@ class CommunityDetailScreen(
|
||||
modifier = Modifier.onClick(
|
||||
onClick = rememberCallback {
|
||||
val sheet = SortBottomSheet(
|
||||
sheetKey = key,
|
||||
values = uiState.availableSortTypes.map { it.toInt() },
|
||||
comments = false,
|
||||
expandTop = true,
|
||||
)
|
||||
navigationCoordinator.showBottomSheet(sheet)
|
||||
@ -290,6 +288,10 @@ class CommunityDetailScreen(
|
||||
this += Option(
|
||||
OptionId.Info, LocalXmlStrings.current.communityDetailInfo
|
||||
)
|
||||
this += Option(
|
||||
OptionId.SetCustomSort,
|
||||
LocalXmlStrings.current.communitySetCustomSort,
|
||||
)
|
||||
this += Option(
|
||||
OptionId.InfoInstance,
|
||||
LocalXmlStrings.current.communityDetailInstanceInfo
|
||||
@ -423,6 +425,15 @@ class CommunityDetailScreen(
|
||||
}
|
||||
}
|
||||
|
||||
OptionId.SetCustomSort -> {
|
||||
val screen = SortBottomSheet(
|
||||
values = uiState.availableSortTypes.map { it.toInt() },
|
||||
defaultForCommunity = true,
|
||||
expandTop = true,
|
||||
)
|
||||
navigationCoordinator.showBottomSheet(screen)
|
||||
}
|
||||
|
||||
else -> Unit
|
||||
}
|
||||
},
|
||||
|
@ -6,6 +6,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.notifications.NotificationC
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.notifications.NotificationCenterEvent
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.data.FavoriteCommunityModel
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.AccountRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.CommunitySortRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.FavoriteCommunityRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.SettingsRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.utils.imagepreload.ImagePreloadManager
|
||||
@ -19,6 +20,8 @@ import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.PostModel
|
||||
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.SortType
|
||||
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.containsId
|
||||
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.imageUrl
|
||||
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.readableHandle
|
||||
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.toInt
|
||||
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.toSortType
|
||||
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.repository.CommunityRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.repository.GetSortTypesUseCase
|
||||
@ -50,6 +53,7 @@ class CommunityDetailViewModel(
|
||||
private val getSortTypesUseCase: GetSortTypesUseCase,
|
||||
private val notificationCenter: NotificationCenter,
|
||||
private val itemCache: LemmyItemCache,
|
||||
private val communitySortRepository: CommunitySortRepository,
|
||||
) : CommunityDetailMviModel,
|
||||
DefaultMviModel<CommunityDetailMviModel.Intent, CommunityDetailMviModel.UiState, CommunityDetailMviModel.Effect>(
|
||||
initialState = CommunityDetailMviModel.UiState(),
|
||||
@ -139,6 +143,10 @@ class CommunityDetailViewModel(
|
||||
}.launchIn(this)
|
||||
notificationCenter.subscribe(NotificationCenterEvent.ChangeSortType::class)
|
||||
.onEach { evt ->
|
||||
if (evt.defaultForCommunity) {
|
||||
val handle = uiState.value.community.readableHandle
|
||||
communitySortRepository.saveSort(handle, evt.value.toInt())
|
||||
}
|
||||
applySortType(evt.value)
|
||||
}.launchIn(this)
|
||||
notificationCenter.subscribe(NotificationCenterEvent.Share::class).onEach { evt ->
|
||||
@ -151,9 +159,10 @@ class CommunityDetailViewModel(
|
||||
updateState { it.copy(currentUserId = user?.id ?: 0) }
|
||||
}
|
||||
if (uiState.value.posts.isEmpty()) {
|
||||
val defaultPostSortType =
|
||||
settingsRepository.currentSettings.value.defaultPostSortType
|
||||
updateState { it.copy(sortType = defaultPostSortType.toSortType()) }
|
||||
val defaultPostSortType = settingsRepository.currentSettings.value.defaultPostSortType.toSortType()
|
||||
val customPostSortType =
|
||||
communitySortRepository.getSort(uiState.value.community.readableHandle)?.toSortType()
|
||||
updateState { it.copy(sortType = customPostSortType ?: defaultPostSortType) }
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
@ -206,7 +215,6 @@ class CommunityDetailViewModel(
|
||||
}
|
||||
|
||||
CommunityDetailMviModel.Intent.HapticIndication -> hapticFeedback.vibrate()
|
||||
is CommunityDetailMviModel.Intent.ChangeSort -> applySortType(intent.value)
|
||||
CommunityDetailMviModel.Intent.Subscribe -> subscribe()
|
||||
CommunityDetailMviModel.Intent.Unsubscribe -> unsubscribe()
|
||||
is CommunityDetailMviModel.Intent.DeletePost -> handlePostDelete(intent.id)
|
||||
|
@ -25,6 +25,7 @@ val communityDetailModule = module {
|
||||
accountRepository = get(),
|
||||
favoriteCommunityRepository = get(),
|
||||
itemCache = get(),
|
||||
communitySortRepository = get(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ interface InstanceInfoMviModel :
|
||||
sealed interface Intent {
|
||||
data object Refresh : Intent
|
||||
data object LoadNextPage : Intent
|
||||
data class ChangeSortType(val value: SortType) : Intent
|
||||
}
|
||||
|
||||
data class UiState(
|
||||
|
@ -134,8 +134,6 @@ class InstanceInfoScreen(
|
||||
modifier = Modifier.onClick(
|
||||
onClick = rememberCallback {
|
||||
val sheet = SortBottomSheet(
|
||||
sheetKey = key,
|
||||
comments = false,
|
||||
values = uiState.availableSortTypes.map { it.toInt() },
|
||||
expandTop = true,
|
||||
)
|
||||
|
@ -72,7 +72,6 @@ class InstanceInfoViewModel(
|
||||
when (intent) {
|
||||
InstanceInfoMviModel.Intent.LoadNextPage -> loadNextPage()
|
||||
InstanceInfoMviModel.Intent.Refresh -> refresh()
|
||||
is InstanceInfoMviModel.Intent.ChangeSortType -> changeSortType(intent.value)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,6 @@ interface MultiCommunityMviModel :
|
||||
sealed interface Intent {
|
||||
data object Refresh : Intent
|
||||
data object LoadNextPage : Intent
|
||||
data class ChangeSort(val value: SortType) : Intent
|
||||
data object HapticIndication : Intent
|
||||
data class UpVotePost(val id: Int, val feedback: Boolean = false) : Intent
|
||||
data class DownVotePost(val id: Int, val feedback: Boolean = false) : Intent
|
||||
|
@ -185,9 +185,7 @@ class MultiCommunityScreen(
|
||||
modifier = Modifier.onClick(
|
||||
onClick = rememberCallback {
|
||||
val sheet = SortBottomSheet(
|
||||
sheetKey = key,
|
||||
values = uiState.availableSortTypes.map { it.toInt() },
|
||||
comments = false,
|
||||
expandTop = true,
|
||||
)
|
||||
navigationCoordinator.showBottomSheet(sheet)
|
||||
|
@ -109,7 +109,6 @@ class MultiCommunityViewModel(
|
||||
|
||||
override fun reduce(intent: MultiCommunityMviModel.Intent) {
|
||||
when (intent) {
|
||||
is MultiCommunityMviModel.Intent.ChangeSort -> applySortType(intent.value)
|
||||
is MultiCommunityMviModel.Intent.DownVotePost -> {
|
||||
if (intent.feedback) {
|
||||
hapticFeedback.vibrate()
|
||||
|
@ -21,7 +21,6 @@ interface PostDetailMviModel :
|
||||
data object RefreshPost : Intent
|
||||
data object LoadNextPage : Intent
|
||||
data class FetchMoreComments(val parentId: Int) : Intent
|
||||
data class ChangeSort(val value: SortType) : Intent
|
||||
data class UpVotePost(val feedback: Boolean = false) : Intent
|
||||
data class DownVotePost(val feedback: Boolean = false) : Intent
|
||||
data class SavePost(val post: PostModel, val feedback: Boolean = false) : Intent
|
||||
|
@ -217,7 +217,6 @@ class PostDetailScreen(
|
||||
modifier = Modifier.onClick(
|
||||
onClick = rememberCallback {
|
||||
val sheet = SortBottomSheet(
|
||||
sheetKey = key,
|
||||
comments = true,
|
||||
values = uiState.availableSortTypes.map { it.toInt() },
|
||||
)
|
||||
|
@ -244,7 +244,6 @@ class PostDetailViewModel(
|
||||
|
||||
PostDetailMviModel.Intent.RefreshPost -> refreshPost()
|
||||
PostDetailMviModel.Intent.HapticIndication -> hapticFeedback.vibrate()
|
||||
is PostDetailMviModel.Intent.ChangeSort -> applySortType(intent.value)
|
||||
|
||||
is PostDetailMviModel.Intent.DownVoteComment -> {
|
||||
if (intent.feedback) {
|
||||
|
@ -18,7 +18,6 @@ interface PostListMviModel :
|
||||
sealed interface Intent {
|
||||
data object Refresh : Intent
|
||||
data object LoadNextPage : Intent
|
||||
data class ChangeSort(val value: SortType) : Intent
|
||||
data class ChangeListing(val value: ListingType) : Intent
|
||||
data class UpVotePost(val id: Int, val feedback: Boolean = false) : Intent
|
||||
data class DownVotePost(val id: Int, val feedback: Boolean = false) : Intent
|
||||
|
@ -197,7 +197,6 @@ class PostListScreen : Screen {
|
||||
onSelectListingType = rememberCallback {
|
||||
val sheet = ListingTypeBottomSheet(
|
||||
isLogged = uiState.isLogged,
|
||||
sheetKey = key,
|
||||
)
|
||||
navigationCoordinator.showBottomSheet(sheet)
|
||||
},
|
||||
@ -208,9 +207,7 @@ class PostListScreen : Screen {
|
||||
} else null,
|
||||
onSelectSortType = rememberCallback {
|
||||
val sheet = SortBottomSheet(
|
||||
sheetKey = key,
|
||||
values = uiState.availableSortTypes.map { it.toInt() },
|
||||
comments = false,
|
||||
expandTop = true,
|
||||
)
|
||||
navigationCoordinator.showBottomSheet(sheet)
|
||||
|
@ -179,7 +179,6 @@ class PostListViewModel(
|
||||
refresh()
|
||||
}
|
||||
|
||||
is PostListMviModel.Intent.ChangeSort -> applySortType(intent.value)
|
||||
is PostListMviModel.Intent.ChangeListing -> applyListingType(intent.value)
|
||||
is PostListMviModel.Intent.DownVotePost -> {
|
||||
if (intent.feedback) {
|
||||
|
@ -18,7 +18,6 @@ interface SavedItemsMviModel :
|
||||
sealed interface Intent {
|
||||
data object Refresh : Intent
|
||||
data object LoadNextPage : Intent
|
||||
data class ChangeSort(val value: SortType) : Intent
|
||||
data class ChangeSection(val section: SavedItemsSection) : Intent
|
||||
data class UpVotePost(val id: Int, val feedback: Boolean = false) : Intent
|
||||
data class DownVotePost(val id: Int, val feedback: Boolean = false) : Intent
|
||||
|
@ -113,8 +113,6 @@ class SavedItemsScreen : Screen {
|
||||
modifier = Modifier.onClick(
|
||||
onClick = rememberCallback {
|
||||
val sheet = SortBottomSheet(
|
||||
sheetKey = key,
|
||||
comments = false,
|
||||
values = uiState.availableSortTypes.map { it.toInt() },
|
||||
)
|
||||
navigatorCoordinator.showBottomSheet(sheet)
|
||||
|
@ -145,8 +145,6 @@ class SavedItemsViewModel(
|
||||
post = uiState.value.posts.first { it.id == intent.id },
|
||||
)
|
||||
}
|
||||
|
||||
is SavedItemsMviModel.Intent.ChangeSort -> applySortType(intent.value)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,6 @@ interface UserDetailMviModel :
|
||||
ScreenModel {
|
||||
|
||||
sealed interface Intent {
|
||||
data class ChangeSort(val value: SortType) : Intent
|
||||
data object Refresh : Intent
|
||||
data object LoadNextPage : Intent
|
||||
data class ChangeSection(val section: UserDetailSection) : Intent
|
||||
|
@ -222,9 +222,7 @@ class UserDetailScreen(
|
||||
modifier = Modifier.onClick(
|
||||
onClick = rememberCallback {
|
||||
val sheet = SortBottomSheet(
|
||||
sheetKey = key,
|
||||
values = uiState.availableSortTypes.map { it.toInt() },
|
||||
comments = false,
|
||||
expandTop = true,
|
||||
)
|
||||
navigationCoordinator.showBottomSheet(sheet)
|
||||
@ -424,7 +422,7 @@ class UserDetailScreen(
|
||||
navigationCoordinator.pushScreen(
|
||||
ZoomableImageScreen(
|
||||
url = url,
|
||||
source = uiState.user?.readableHandle.orEmpty(),
|
||||
source = uiState.user.readableHandle,
|
||||
)
|
||||
)
|
||||
},
|
||||
|
@ -133,7 +133,6 @@ class UserDetailViewModel(
|
||||
|
||||
override fun reduce(intent: UserDetailMviModel.Intent) {
|
||||
when (intent) {
|
||||
is UserDetailMviModel.Intent.ChangeSort -> applySortType(intent.value)
|
||||
is UserDetailMviModel.Intent.ChangeSection -> changeSection(intent.section)
|
||||
is UserDetailMviModel.Intent.DownVoteComment -> {
|
||||
if (intent.feedback) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user