Skip to content

Commit

Permalink
[fix, UX] Update kosync login/logout text (#5278)
Browse files Browse the repository at this point in the history
As a side effect of <#4189> some menus have to manually trigger updates.

I'm not overly enthused with this solution but I couldn't think of anything better right now.

Fixes <#5224>.
  • Loading branch information
Frenzie committed Aug 29, 2019
1 parent dd4bfb0 commit 6979e08
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions plugins/kosync.koplugin/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,17 @@ function KOSync:addToMainMenu(menu_items)
end,
keep_menu_open = true,
callback_func = function()
return self.kosync_userkey and
function() self:logout() end or
function() self:login() end
if self.kosync_userkey then
return function(menu)
self._menu_to_update = menu
self:logout()
end
else
return function(menu)
self._menu_to_update = menu
self:login()
end
end
end,
},
{
Expand Down Expand Up @@ -328,6 +336,7 @@ function KOSync:doRegister(username, password)
elseif status then
self.kosync_username = username
self.kosync_userkey = userkey
self._menu_to_update:updateItems()
UIManager:show(InfoMessage:new{
text = _("Registered to KOReader server."),
})
Expand Down Expand Up @@ -363,6 +372,7 @@ function KOSync:doLogin(username, password)
elseif status then
self.kosync_username = username
self.kosync_userkey = userkey
self._menu_to_update:updateItems()
UIManager:show(InfoMessage:new{
text = _("Logged in to KOReader server."),
})
Expand All @@ -378,6 +388,7 @@ end
function KOSync:logout()
self.kosync_userkey = nil
self.kosync_auto_sync = true
self._menu_to_update:updateItems()
self:saveSettings()
end

Expand Down

0 comments on commit 6979e08

Please sign in to comment.