mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-15 15:02:49 +01:00
refactor: flipped the function names.
Signed-off-by: KaiserBh <kaiserbh@proton.me>
This commit is contained in:
parent
7bd9c2f7c0
commit
b987e12db0
@ -61,7 +61,7 @@ class GoogleDriveSyncService(context: Context, json: Json, syncPreferences: Sync
|
|||||||
|
|
||||||
override suspend fun beforeSync() = googleDriveService.refreshToken()
|
override suspend fun beforeSync() = googleDriveService.refreshToken()
|
||||||
|
|
||||||
override suspend fun pushSyncData(): SyncData? {
|
override suspend fun pullSyncData(): SyncData? {
|
||||||
val drive = googleDriveService.googleDriveService
|
val drive = googleDriveService.googleDriveService
|
||||||
|
|
||||||
// Check if the Google Drive service is initialized
|
// Check if the Google Drive service is initialized
|
||||||
@ -87,7 +87,7 @@ class GoogleDriveSyncService(context: Context, json: Json, syncPreferences: Sync
|
|||||||
return json.decodeFromString(SyncData.serializer(), jsonString)
|
return json.decodeFromString(SyncData.serializer(), jsonString)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun pullSyncData(syncData: SyncData) {
|
override suspend fun pushSyncData(syncData: SyncData) {
|
||||||
val jsonData = json.encodeToString(syncData)
|
val jsonData = json.encodeToString(syncData)
|
||||||
|
|
||||||
val drive = googleDriveService.googleDriveService
|
val drive = googleDriveService.googleDriveService
|
||||||
|
@ -23,15 +23,15 @@ abstract class SyncService(
|
|||||||
open suspend fun doSync(syncData: SyncData): Backup? {
|
open suspend fun doSync(syncData: SyncData): Backup? {
|
||||||
beforeSync()
|
beforeSync()
|
||||||
|
|
||||||
val remoteSData = pushSyncData()
|
val remoteSData = pullSyncData()
|
||||||
|
|
||||||
val finalSyncData =
|
val finalSyncData =
|
||||||
if (remoteSData == null) {
|
if (remoteSData == null) {
|
||||||
pullSyncData(syncData)
|
pushSyncData(syncData)
|
||||||
syncData
|
syncData
|
||||||
} else {
|
} else {
|
||||||
val mergedSyncData = mergeSyncData(syncData, remoteSData)
|
val mergedSyncData = mergeSyncData(syncData, remoteSData)
|
||||||
pullSyncData(mergedSyncData)
|
pushSyncData(mergedSyncData)
|
||||||
mergedSyncData
|
mergedSyncData
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,12 +46,12 @@ abstract class SyncService(
|
|||||||
/**
|
/**
|
||||||
* Download sync data from the remote storage
|
* Download sync data from the remote storage
|
||||||
*/
|
*/
|
||||||
abstract suspend fun pushSyncData(): SyncData?
|
abstract suspend fun pullSyncData(): SyncData?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload sync data to the remote storage
|
* Upload sync data to the remote storage
|
||||||
*/
|
*/
|
||||||
abstract suspend fun pullSyncData(syncData: SyncData)
|
abstract suspend fun pushSyncData(syncData: SyncData)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merges the local and remote sync data into a single JSON string.
|
* Merges the local and remote sync data into a single JSON string.
|
||||||
|
@ -22,7 +22,7 @@ class SyncYomiSyncService(
|
|||||||
syncPreferences: SyncPreferences,
|
syncPreferences: SyncPreferences,
|
||||||
private val notifier: SyncNotifier,
|
private val notifier: SyncNotifier,
|
||||||
) : SyncService(context, json, syncPreferences) {
|
) : SyncService(context, json, syncPreferences) {
|
||||||
override suspend fun pushSyncData(): SyncData? {
|
override suspend fun pullSyncData(): SyncData? {
|
||||||
val host = syncPreferences.syncHost().get()
|
val host = syncPreferences.syncHost().get()
|
||||||
val apiKey = syncPreferences.syncAPIKey().get()
|
val apiKey = syncPreferences.syncAPIKey().get()
|
||||||
val downloadUrl = "$host/api/sync/download"
|
val downloadUrl = "$host/api/sync/download"
|
||||||
@ -48,7 +48,7 @@ class SyncYomiSyncService(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun pullSyncData(syncData: SyncData) {
|
override suspend fun pushSyncData(syncData: SyncData) {
|
||||||
val host = syncPreferences.syncHost().get()
|
val host = syncPreferences.syncHost().get()
|
||||||
val apiKey = syncPreferences.syncAPIKey().get()
|
val apiKey = syncPreferences.syncAPIKey().get()
|
||||||
val uploadUrl = "$host/api/sync/upload"
|
val uploadUrl = "$host/api/sync/upload"
|
||||||
|
Loading…
Reference in New Issue
Block a user