Skip to content
Merged
Show file tree
Hide file tree
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
46 changes: 22 additions & 24 deletions grimmory.koplugin/grimmory/ui/dialog_manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -365,41 +365,39 @@ function DialogManager:showProgressDialog(title, dismiss_callback, dismiss_text)
local confirm_dialog
local is_closing = false

if dismiss_callback ~= nil then
if dismiss_text == nil then
dismiss_text = _("Terminate this task?")
end
if dismiss_text == nil then
dismiss_text = _("Terminate this task?")
end

dismiss_callback = function()
if is_closing then
-- The dismiss callback is fired even when
-- an outside force is trying to close the
-- dialog.
return
end
local confirm_dismiss = function()
if is_closing then
-- The dismiss callback is fired even when
-- an outside force is trying to close the
-- dialog.
return
end

if confirm_dialog then
UIManager:close(confirm_dialog)
end
if confirm_dialog then
UIManager:close(confirm_dialog)
end

confirm_dialog = ConfirmBox:new({
text = dismiss_text,
ok_callback = function()
pcall(dismiss_callback)
UIManager:close(dialog)
end,
})
confirm_dialog = ConfirmBox:new({
text = dismiss_text,
ok_callback = function()
pcall(dismiss_callback)
UIManager:close(dialog)
end,
})

UIManager:show(confirm_dialog)
end
UIManager:show(confirm_dialog)
end

dialog = ProgressbarDialog:new({
title = _(title),
progress_max = 100,
refresh_time_seconds = 3,
dismissable = dismiss_callback ~= nil,
dismiss_callback = dismiss_callback,
dismiss_callback = confirm_dismiss,
})

UIManager:show(dialog)
Expand Down
20 changes: 15 additions & 5 deletions grimmory.koplugin/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,22 @@ function Grimmory:onGrimmorySync(verbose)
end

if not ok then
logger:err("Failed sync", result)
if should_terminate then
logger:info("Sync was interrupted by user")

if verbose then
self.dialog_manager:toast(
T(_("Failed to Synchronize to Grimmory"))
)
if verbose then
self.dialog_manager:toast(
_("Grimmory synchronization has been interrupted")
)
end
else
logger:err("Failed sync", result)

if verbose then
self.dialog_manager:toast(
_("Failed to Synchronize to Grimmory")
)
end
end

return
Expand Down
Loading