mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 00:11:37 -06:00
feat(koreader): add option to skip auto-sync when offline
When enabled, automatic sync on book open will be skipped if the device is not online, preventing stalls from Wi-Fi connection attempts. Closes #471
This commit is contained in:
@@ -67,6 +67,7 @@ BookOrbit.default_settings = {
|
||||
username = nil,
|
||||
userkey = nil,
|
||||
auto_sync = false,
|
||||
skip_sync_when_offline = false,
|
||||
annotation_sync = true,
|
||||
pages_before_update = 10,
|
||||
sync_forward = SYNC_STRATEGY.PROMPT,
|
||||
@@ -273,10 +274,16 @@ end
|
||||
function BookOrbit:onReaderReady()
|
||||
if self.settings.auto_sync then
|
||||
UIManager:nextTick(function()
|
||||
if self.settings.skip_sync_when_offline and not NetworkMgr:isOnline() then
|
||||
return
|
||||
end
|
||||
self:getProgress(true, false)
|
||||
end)
|
||||
if self.settings.annotation_sync then
|
||||
UIManager:scheduleIn(2, function()
|
||||
if self.settings.skip_sync_when_offline and not NetworkMgr:isOnline() then
|
||||
return
|
||||
end
|
||||
self:exchangeAnnotationsForOpenBook()
|
||||
end)
|
||||
end
|
||||
@@ -472,6 +479,15 @@ function BookOrbit:addToMainMenu(menu_items)
|
||||
callback = function()
|
||||
self.settings.annotation_sync = not self.settings.annotation_sync
|
||||
end,
|
||||
},
|
||||
{
|
||||
text = _("Skip auto-sync when offline"),
|
||||
checked_func = function() return self.settings.skip_sync_when_offline end,
|
||||
enabled_func = function() return self.settings.auto_sync end,
|
||||
help_text = _([[When enabled, automatic sync on book open is skipped if the device is not already online. Prevents the e-reader from stalling while trying to connect to Wi-Fi.]]),
|
||||
callback = function()
|
||||
self.settings.skip_sync_when_offline = not self.settings.skip_sync_when_offline
|
||||
end,
|
||||
separator = true,
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user