mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Fix addon update dialog showing twice (#2580)
* Gitignore .ninja_deps * Don't check for addon updates on profile unload This fixes two update dialogs showing up when switching profiles. * Only show addon update dialog once ... instead of once every time the profile is changed, when the version doesn't match. This is analogous to when the dialog is triggered by elapsed time. * Manage last_run_version update in ProfileManager
This commit is contained in:
parent
ca41dfeb3d
commit
9430e3ddf2
3 changed files with 9 additions and 16 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -12,3 +12,4 @@ target
|
||||||
node_modules
|
node_modules
|
||||||
.n2_db
|
.n2_db
|
||||||
.ninja_log
|
.ninja_log
|
||||||
|
.ninja_deps
|
||||||
|
|
|
@ -498,6 +498,8 @@ class AnkiQt(QMainWindow):
|
||||||
self._refresh_after_sync()
|
self._refresh_after_sync()
|
||||||
if onsuccess:
|
if onsuccess:
|
||||||
onsuccess()
|
onsuccess()
|
||||||
|
if not self.safeMode:
|
||||||
|
self.maybe_check_for_addon_updates(self.setupAutoUpdate)
|
||||||
|
|
||||||
self.maybe_auto_sync_on_open_close(_onsuccess)
|
self.maybe_auto_sync_on_open_close(_onsuccess)
|
||||||
|
|
||||||
|
@ -952,7 +954,7 @@ title="{}" {}>{}</button>""".format(
|
||||||
if on_done:
|
if on_done:
|
||||||
on_done()
|
on_done()
|
||||||
|
|
||||||
if elap > 86_400 or self.pm.last_run_version() != point_version():
|
if elap > 86_400 or self.pm.last_run_version != point_version():
|
||||||
check_and_prompt_for_updates(
|
check_and_prompt_for_updates(
|
||||||
self,
|
self,
|
||||||
self.addonManager,
|
self.addonManager,
|
||||||
|
@ -1033,16 +1035,10 @@ title="{}" {}>{}</button>""".format(
|
||||||
|
|
||||||
def maybe_auto_sync_on_open_close(self, after_sync: Callable[[], None]) -> None:
|
def maybe_auto_sync_on_open_close(self, after_sync: Callable[[], None]) -> None:
|
||||||
"If disabled, after_sync() is called immediately."
|
"If disabled, after_sync() is called immediately."
|
||||||
|
|
||||||
def after_sync_and_call_addon_update() -> None:
|
|
||||||
after_sync()
|
|
||||||
if not self.safeMode:
|
|
||||||
self.maybe_check_for_addon_updates(self.setupAutoUpdate)
|
|
||||||
|
|
||||||
if self.can_auto_sync():
|
if self.can_auto_sync():
|
||||||
self._sync_collection_and_media(after_sync_and_call_addon_update)
|
self._sync_collection_and_media(after_sync)
|
||||||
else:
|
else:
|
||||||
after_sync_and_call_addon_update()
|
after_sync()
|
||||||
|
|
||||||
def maybe_auto_sync_media(self) -> None:
|
def maybe_auto_sync_media(self) -> None:
|
||||||
if self.can_auto_sync():
|
if self.can_auto_sync():
|
||||||
|
@ -1154,7 +1150,6 @@ title="{}" {}>{}</button>""".format(
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
def closeEvent(self, event: QCloseEvent) -> None:
|
def closeEvent(self, event: QCloseEvent) -> None:
|
||||||
self.pm.set_last_run_version()
|
|
||||||
if self.state == "profileManager":
|
if self.state == "profileManager":
|
||||||
# if profile manager active, this event may fire via OS X menu bar's
|
# if profile manager active, this event may fire via OS X menu bar's
|
||||||
# quit option
|
# quit option
|
||||||
|
|
|
@ -117,6 +117,7 @@ class LoadMetaResult:
|
||||||
|
|
||||||
class ProfileManager:
|
class ProfileManager:
|
||||||
default_answer_keys = {ease_num: str(ease_num) for ease_num in range(1, 5)}
|
default_answer_keys = {ease_num: str(ease_num) for ease_num in range(1, 5)}
|
||||||
|
last_run_version: int = 0
|
||||||
|
|
||||||
def __init__(self, base: Path) -> None: #
|
def __init__(self, base: Path) -> None: #
|
||||||
"base should be retrieved via ProfileMangager.get_created_base_folder"
|
"base should be retrieved via ProfileMangager.get_created_base_folder"
|
||||||
|
@ -132,6 +133,8 @@ class ProfileManager:
|
||||||
# load metadata
|
# load metadata
|
||||||
res = self._loadMeta()
|
res = self._loadMeta()
|
||||||
self.firstRun = res.firstTime
|
self.firstRun = res.firstTime
|
||||||
|
self.last_run_version = self.meta.get("last_run_version", self.last_run_version)
|
||||||
|
self.meta["last_run_version"] = point_version()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
# -p profile provided on command line.
|
# -p profile provided on command line.
|
||||||
|
@ -506,12 +509,6 @@ create table if not exists profiles
|
||||||
# Shared options
|
# Shared options
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def last_run_version(self) -> int:
|
|
||||||
return self.meta.get("last_run_version", 0)
|
|
||||||
|
|
||||||
def set_last_run_version(self) -> None:
|
|
||||||
self.meta["last_run_version"] = point_version()
|
|
||||||
|
|
||||||
def uiScale(self) -> float:
|
def uiScale(self) -> float:
|
||||||
scale = self.meta.get("uiScale", 1.0)
|
scale = self.meta.get("uiScale", 1.0)
|
||||||
return max(scale, 1)
|
return max(scale, 1)
|
||||||
|
|
Loading…
Reference in a new issue