feat: added triggers for syncing.

Experimental for now, but works fine so far, I don't know about google api limit but I think it's pretty generous.

Signed-off-by: KaiserBh <kaiserbh@proton.me>
This commit is contained in:
KaiserBh
2023-12-20 22:12:46 +11:00
parent cc5e14088c
commit 178b00280b
6 changed files with 181 additions and 1 deletions

View File

@@ -6,6 +6,18 @@ import tachiyomi.core.preference.PreferenceStore
class SyncPreferences(
private val preferenceStore: PreferenceStore,
) {
object Flags {
const val NONE = 0x0
const val SYNC_ON_CHAPTER_READ = 0x1
const val SYNC_ON_CHAPTER_OPEN = 0x2
const val SYNC_ON_APP_START = 0x4
const val Defaults = NONE
fun values() = listOf(NONE, SYNC_ON_CHAPTER_READ, SYNC_ON_CHAPTER_OPEN, SYNC_ON_APP_START)
}
fun syncHost() = preferenceStore.getString("sync_host", "https://sync.tachiyomi.org")
fun syncAPIKey() = preferenceStore.getString("sync_api_key", "")
fun lastSyncTimestamp() = preferenceStore.getLong(Preference.appStateKey("last_sync_timestamp"), 0L)
@@ -22,4 +34,6 @@ class SyncPreferences(
Preference.appStateKey("google_drive_refresh_token"),
"",
)
fun syncFlags() = preferenceStore.getInt("sync_flags", Flags.Defaults)
}