From 6979e080f82e53a4f3e28037343e186c264e5657 Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Thu, 29 Aug 2019 10:05:49 +0200 Subject: [PATCH] [fix, UX] Update kosync login/logout text (#5278) As a side effect of 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 . --- plugins/kosync.koplugin/main.lua | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/plugins/kosync.koplugin/main.lua b/plugins/kosync.koplugin/main.lua index e0c2cb0a2..46f8cab43 100644 --- a/plugins/kosync.koplugin/main.lua +++ b/plugins/kosync.koplugin/main.lua @@ -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, }, { @@ -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."), }) @@ -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."), }) @@ -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