Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ import kotlinx.coroutines.withContext
import net.ankiweb.rsdroid.Translations
import timber.log.Timber
import java.io.File
import kotlin.time.Duration
import kotlin.time.Duration.Companion.minutes

/**
* The current entry point for AnkiDroid. Displays decks, allowing users to study. Many other functions.
Expand Down Expand Up @@ -1410,10 +1412,8 @@ open class DeckPicker :
}
}

fun syncIntervalPassed(): Boolean {
val automaticSyncIntervalInMS = AUTOMATIC_SYNC_MINIMAL_INTERVAL_IN_MINUTES * 60 * 1000
return TimeManager.time.intTimeMS() - Prefs.lastSyncTime > automaticSyncIntervalInMS
}
fun syncIntervalPassed(): Boolean =
(TimeManager.time.intTimeMS() - Prefs.lastSyncTime) > AUTOMATIC_SYNC_MINIMAL_INTERVAL.inWholeMilliseconds

when {
!Prefs.isAutoSyncEnabled -> Timber.d("autoSync: not enabled")
Expand Down Expand Up @@ -2181,9 +2181,12 @@ open class DeckPicker :
@VisibleForTesting
const val REQUEST_STORAGE_PERMISSION = 0

// For automatic syncing
// 10 minutes in milliseconds..
private const val AUTOMATIC_SYNC_MINIMAL_INTERVAL_IN_MINUTES: Long = 10
/**
* Minimum delay between automatic syncs.
*
* Skips the automatic sync if this time has not elapsed.
*/
private val AUTOMATIC_SYNC_MINIMAL_INTERVAL: Duration = 10.minutes
private const val SWIPE_TO_SYNC_TRIGGER_DISTANCE = 400

private const val PREF_DECK_PICKER_PANE_WEIGHT = "deckPickerPaneWeight"
Expand Down
Loading