From 1b4d08bbbaec4356c9af5c510277e7a19a400ffa Mon Sep 17 00:00:00 2001 From: tapframe <85391825+tapframe@users.noreply.github.com> Date: Fri, 26 Jun 2026 15:01:34 +0530 Subject: [PATCH] feat: support for 6 profiles --- .../kotlin/com/nuvio/app/features/profiles/ProfileModels.kt | 2 ++ .../com/nuvio/app/features/profiles/ProfileRepository.kt | 5 +++-- .../nuvio/app/features/profiles/ProfileSelectionScreen.kt | 2 +- .../com/nuvio/app/features/profiles/ProfileSwitcherTab.kt | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/profiles/ProfileModels.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/profiles/ProfileModels.kt index 32f0dc00a..9f70c6981 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/profiles/ProfileModels.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/profiles/ProfileModels.kt @@ -5,6 +5,8 @@ import com.nuvio.app.core.network.SyncBackendRepository import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable +const val MAX_PROFILES = 6 + @Serializable data class NuvioProfile( val id: String = "", diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/profiles/ProfileRepository.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/profiles/ProfileRepository.kt index cbc1c5545..279c1080a 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/profiles/ProfileRepository.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/profiles/ProfileRepository.kt @@ -185,6 +185,7 @@ object ProfileRepository { } try { val params = buildJsonObject { + put("p_client_max_profiles", MAX_PROFILES) put("p_profiles", json.encodeToJsonElement(profiles)) } SupabaseProvider.client.postgrest.rpc("sync_push_profiles", params) @@ -203,7 +204,7 @@ object ProfileRepository { usesPrimaryAddons: Boolean = false, ) { val existing = _state.value.profiles - val nextIndex = ((1..4).toSet() - existing.map { it.profileIndex }.toSet()).minOrNull() ?: return + val nextIndex = ((1..MAX_PROFILES).toSet() - existing.map { it.profileIndex }.toSet()).minOrNull() ?: return val allPayloads = existing.map { profile -> ProfilePushPayload( @@ -478,7 +479,7 @@ object ProfileRepository { private fun syncPinCache(profiles: List) { val profilesByIndex = profiles.associateBy { it.profileIndex } - for (profileIndex in 1..4) { + for (profileIndex in 1..MAX_PROFILES) { val profile = profilesByIndex[profileIndex] if (profile == null || !profile.pinEnabled) { ProfilePinCacheStorage.removePayload(profileIndex) diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/profiles/ProfileSelectionScreen.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/profiles/ProfileSelectionScreen.kt index 25761a450..012fd406c 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/profiles/ProfileSelectionScreen.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/profiles/ProfileSelectionScreen.kt @@ -147,7 +147,7 @@ fun ProfileSelectionScreen( Spacer(modifier = Modifier.height(if (isTabletLayout) 28.dp else 48.dp)) val profiles = profileState.profiles - val items = profiles.size + if (profiles.size < 4) 1 else 0 + val items = profiles.size + if (profiles.size < MAX_PROFILES) 1 else 0 if (isTabletLayout) { Box( diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/profiles/ProfileSwitcherTab.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/profiles/ProfileSwitcherTab.kt index 5e9b47952..3b8d0a5fc 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/profiles/ProfileSwitcherTab.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/profiles/ProfileSwitcherTab.kt @@ -295,7 +295,7 @@ fun ProfileSwitcherTab( ) } - if (profiles.size < 4) { + if (profiles.size < MAX_PROFILES) { PopupAddProfileBubble( delayMs = profiles.size * 50, onClick = { @@ -473,7 +473,7 @@ fun NativeProfileSwitcherPopup( ) } - if (profiles.size < 4) { + if (profiles.size < MAX_PROFILES) { PopupAddProfileBubble( delayMs = profiles.size * 50, onClick = {