From 089cda5e56ae5aaf34b7bff6757a65f6e1cd32d0 Mon Sep 17 00:00:00 2001 From: Valentin Buira Date: Tue, 3 Dec 2024 13:25:08 +0100 Subject: [PATCH] * Remove useless "post_login" and "mc.user_service()" * Handle new ClientError from "mc.workspace_service" --- Mergin/plugin.py | 58 +++++++++++++----------------------------------- 1 file changed, 15 insertions(+), 43 deletions(-) diff --git a/Mergin/plugin.py b/Mergin/plugin.py index b058771..e5d6b3d 100644 --- a/Mergin/plugin.py +++ b/Mergin/plugin.py @@ -158,8 +158,6 @@ def initGui(self): self.enable_toolbar_actions() - self.post_login() - self.data_item_provider = DataItemProvider(self) QgsApplication.instance().dataItemProviderRegistry().addProvider(self.data_item_provider) # related to https://github.com/MerginMaps/qgis-mergin-plugin/issues/3 @@ -249,7 +247,6 @@ def on_config_changed(self): """Called when plugin config (connection settings) were changed.""" self.create_manager() self.enable_toolbar_actions() - self.post_login() def open_configured_url(self, path=None): """Opens configured Mergin Maps server url in default browser @@ -351,20 +348,21 @@ def set_current_workspace(self, workspace): if self.mc.server_type() == ServerType.SAAS and workspace_id: # check action required flag - service_response = self.mc.workspace_service(workspace_id) - - if service_response and type(service_response) is dict: - requires_action = service_response.get("action_required", False) - - if requires_action: - iface.messageBar().pushMessage( - "Mergin Maps", - "Your attention is required. Please visit the " - f"" - "Mergin dashboard", - level=Qgis.Critical, - duration=0, - ) + try: + service_response = self.mc.workspace_service(workspace_id) + except ClientError as e: + return + + requires_action = service_response.get("action_required", False) + if requires_action: + iface.messageBar().pushMessage( + "Mergin Maps", + "Your attention is required. Please visit the " + f"" + "Mergin dashboard", + level=Qgis.Critical, + duration=0, + ) def choose_active_workspace(self): """ @@ -402,32 +400,6 @@ def choose_active_workspace(self): self.set_current_workspace(workspace) - def post_login(self): - """Groups actions that needs to be done when auth information changes""" - if not self.mc: - return - - if self.mc.server_type() != ServerType.OLD: - return - - settings = QSettings() - - # check action required flag - service_response = self.mc.user_service() - - if service_response and type(service_response) is dict: - requires_action = service_response.get("action_required", False) - - if requires_action: - iface.messageBar().pushMessage( - "Mergin Maps", - "Your attention is required. Please visit the " - f"" - "Mergin dashboard", - level=Qgis.Critical, - duration=0, - ) - def create_new_project(self): """Open new Mergin Maps project creation dialog.""" check_result = unsaved_project_check()