Skip to content

Commit

Permalink
Download database when connecting iCloud
Browse files Browse the repository at this point in the history
  • Loading branch information
prof18 committed Jul 29, 2024
1 parent 3cfd3fd commit a7c26b8
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 46 deletions.
2 changes: 1 addition & 1 deletion iosApp/FeedFlow.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@
shared,
"-lsqlite3",
);
PRODUCT_BUNDLE_IDENTIFIER = com.prof18.feedflow.debug;
PRODUCT_BUNDLE_IDENTIFIER = com.prof18.feedflow.dev;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
Expand Down
54 changes: 27 additions & 27 deletions iosApp/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,21 @@
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>VERSION_NAME</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string></string>
<key>CFBundleURLSchemes</key>
<array>
<string>$(DROPBOX_URL_SCHEME)</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>VERSION_CODE</string>
<key>DropboxApiKey</key>
<string>$(DROPBOX_API_KEY)</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand All @@ -39,8 +52,8 @@
<string>brave</string>
<string>googlechromes</string>
<string>firefox-focus</string>
<string>dbapi-8-emm</string>
<string>dbapi-2</string>
<string>dbapi-8-emm</string>
<string>dbapi-2</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
Expand All @@ -49,6 +62,18 @@
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSUbiquitousContainers</key>
<dict>
<key>iCloud.com.prof18.feedflow</key>
<dict>
<key>NSUbiquitousContainerIsDocumentScopePublic</key>
<true/>
<key>NSUbiquitousContainerName</key>
<string>FeedFlow</string>
<key>NSUbiquitousContainerSupportedFolderLevels</key>
<string>Any</string>
</dict>
</dict>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
Expand All @@ -73,30 +98,5 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>$(DROPBOX_URL_SCHEME)</string>
</array>
<key>CFBundleURLName</key>
<string></string>
</dict>
</array>
<key>DropboxApiKey</key>
<string>$(DROPBOX_API_KEY)</string>
<key>NSUbiquitousContainers</key>
<dict>
<key>iCloud.com.prof18.feedflow</key>
<dict>
<key>NSUbiquitousContainerIsDocumentScopePublic</key>
<true/>
<key>NSUbiquitousContainerName</key>
<string>FeedFlow</string>
<key>NSUbiquitousContainerSupportedFolderLevels</key>
<string>Any</string>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ internal actual fun getPlatformModule(appEnvironment: AppEnvironment): Module =
accountsRepository = get(),
feedSyncMessageQueue = get(),
feedSyncRepository = get(),
feedRetrieverRepository = get(),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.prof18.feedflow.core.model.AccountConnectionUiState
import com.prof18.feedflow.core.model.AccountSyncUIState
import com.prof18.feedflow.feedsync.icloud.ICloudSettings
import com.prof18.feedflow.shared.domain.DateFormatter
import com.prof18.feedflow.shared.domain.feed.retriever.FeedRetrieverRepository
import com.prof18.feedflow.shared.domain.feedsync.AccountsRepository
import com.prof18.feedflow.shared.domain.feedsync.FeedSyncMessageQueue
import com.prof18.feedflow.shared.domain.feedsync.FeedSyncRepository
Expand All @@ -20,6 +21,7 @@ class ICloudSyncViewModel internal constructor(
private val dateFormatter: DateFormatter,
private val accountsRepository: AccountsRepository,
private val feedSyncRepository: FeedSyncRepository,
private val feedRetrieverRepository: FeedRetrieverRepository,
feedSyncMessageQueue: FeedSyncMessageQueue,
) : BaseViewModel() {

Expand All @@ -38,20 +40,20 @@ class ICloudSyncViewModel internal constructor(
}

fun setICloudAuth() {
iCloudSettings.setUseICloud(true)
accountsRepository.setICloudAccount()
iCloudSyncUiMutableState.update {
AccountConnectionUiState.Linked(
syncState = getSyncState(),
)
scope.launch {
iCloudSettings.setUseICloud(true)
accountsRepository.setICloudAccount()
iCloudSyncUiMutableState.update {
AccountConnectionUiState.Linked(
syncState = getSyncState(),
)
}
emitSyncLoading()
accountsRepository.setICloudAccount()
feedSyncRepository.firstSync()
feedRetrieverRepository.fetchFeeds()
emitLastSyncUpdate()
}
/*
emitSyncLoading()
accountsRepository.setDropboxAccount()
feedSyncRepository.firstSync()
feedRetrieverRepository.fetchFeeds()
emitLastSyncUpdate()
*/
}

fun triggerBackup() {
Expand All @@ -63,11 +65,12 @@ class ICloudSyncViewModel internal constructor(
}

fun unlink() {
iCloudSettings.setUseICloud(false)
// feedSyncRepository.deleteAll()
accountsRepository.clearAccount()
iCloudSyncUiMutableState.update {
AccountConnectionUiState.Unlinked
scope.launch {
iCloudSyncUiMutableState.update { AccountConnectionUiState.Loading }
iCloudSettings.setUseICloud(false)
feedSyncRepository.deleteAll()
accountsRepository.clearAccount()
iCloudSyncUiMutableState.update { AccountConnectionUiState.Unlinked }
}
}

Expand Down

0 comments on commit a7c26b8

Please sign in to comment.