mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-20 05:07:50 -06:00
Fix typing issue in CloudPackageChecker
CURA-7290
This commit is contained in:
parent
b40b8e8489
commit
fbc0be30ec
1 changed files with 8 additions and 9 deletions
|
@ -2,7 +2,7 @@
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from typing import List, Dict, Any
|
from typing import List, Dict, Any, Set
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from PyQt5.QtCore import QObject
|
from PyQt5.QtCore import QObject
|
||||||
|
@ -36,9 +36,8 @@ class CloudPackageChecker(QObject):
|
||||||
self._application.initializationFinished.connect(self._onAppInitialized)
|
self._application.initializationFinished.connect(self._onAppInitialized)
|
||||||
self._i18n_catalog = i18nCatalog("cura")
|
self._i18n_catalog = i18nCatalog("cura")
|
||||||
self._sdk_version = ApplicationMetadata.CuraSDKVersion
|
self._sdk_version = ApplicationMetadata.CuraSDKVersion
|
||||||
self._last_check_packages = [] # type: List[str]
|
self._last_notified_packages = set() # type: Set[str]
|
||||||
"""Result from a previous check within the same user session.
|
"""Packages for which a notification has been shown. No need to bother the user twice fo equal content"""
|
||||||
Used to prevent duplicate notifications"""
|
|
||||||
|
|
||||||
# This is a plugin, so most of the components required are not ready when
|
# This is a plugin, so most of the components required are not ready when
|
||||||
# this is initialized. Therefore, we wait until the application is ready.
|
# this is initialized. Therefore, we wait until the application is ready.
|
||||||
|
@ -52,7 +51,7 @@ class CloudPackageChecker(QObject):
|
||||||
|
|
||||||
def _onLoginStateChanged(self) -> None:
|
def _onLoginStateChanged(self) -> None:
|
||||||
# reset session
|
# reset session
|
||||||
self._last_check_packages = []
|
self._last_notified_packages = set()
|
||||||
self._getPackagesIfLoggedIn()
|
self._getPackagesIfLoggedIn()
|
||||||
|
|
||||||
def _getPackagesIfLoggedIn(self) -> None:
|
def _getPackagesIfLoggedIn(self) -> None:
|
||||||
|
@ -96,8 +95,8 @@ class CloudPackageChecker(QObject):
|
||||||
user_subscribed_packages = {plugin["package_id"] for plugin in subscribed_packages_payload}
|
user_subscribed_packages = {plugin["package_id"] for plugin in subscribed_packages_payload}
|
||||||
user_installed_packages = self._package_manager.getAllInstalledPackageIDs()
|
user_installed_packages = self._package_manager.getAllInstalledPackageIDs()
|
||||||
|
|
||||||
if user_subscribed_packages == self._last_check_packages:
|
if user_subscribed_packages == self._last_notified_packages:
|
||||||
# nothing new here
|
# already notified user about these
|
||||||
return
|
return
|
||||||
|
|
||||||
# We need to re-evaluate the dismissed packages
|
# We need to re-evaluate the dismissed packages
|
||||||
|
@ -109,13 +108,13 @@ class CloudPackageChecker(QObject):
|
||||||
user_installed_packages += user_dismissed_packages
|
user_installed_packages += user_dismissed_packages
|
||||||
|
|
||||||
# We check if there are packages installed in Web Marketplace but not in Cura marketplace
|
# We check if there are packages installed in Web Marketplace but not in Cura marketplace
|
||||||
package_discrepancy = list(set(user_subscribed_packages).difference(user_installed_packages))
|
package_discrepancy = list(user_subscribed_packages.difference(user_installed_packages))
|
||||||
if package_discrepancy:
|
if package_discrepancy:
|
||||||
Logger.log("d", "Discrepancy found between Cloud subscribed packages and Cura installed packages")
|
Logger.log("d", "Discrepancy found between Cloud subscribed packages and Cura installed packages")
|
||||||
self._model.addDiscrepancies(package_discrepancy)
|
self._model.addDiscrepancies(package_discrepancy)
|
||||||
self._model.initialize(self._package_manager, subscribed_packages_payload)
|
self._model.initialize(self._package_manager, subscribed_packages_payload)
|
||||||
self._showSyncMessage()
|
self._showSyncMessage()
|
||||||
self._last_check_packages = user_subscribed_packages
|
self._last_notified_packages = user_subscribed_packages
|
||||||
|
|
||||||
def _showSyncMessage(self) -> None:
|
def _showSyncMessage(self) -> None:
|
||||||
"""Show the message if it is not already shown"""
|
"""Show the message if it is not already shown"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue