diff --git a/TODO.md b/TODO.md index acdc2aba..b2620334 100644 --- a/TODO.md +++ b/TODO.md @@ -45,7 +45,6 @@ - Make links in room subtitle clickable, formatting? - `
` scrollbar on overflow
   - Handle cases where an avatar char is # or @ (#alias room, @user\_id)
-  - Proper logoff when closing client
   - When inviting someone to direct chat, room is "Empty room" until accepted,
     it should be the peer's display name instead.
   - Keep an accounts order
diff --git a/harmonyqml/backend/backend.py b/harmonyqml/backend/backend.py
index 3e3735cf..be513e28 100644
--- a/harmonyqml/backend/backend.py
+++ b/harmonyqml/backend/backend.py
@@ -1,10 +1,12 @@
 # Copyright 2019 miruka
 # This file is part of harmonyqml, licensed under GPLv3.
 
+import os
 from concurrent.futures import ThreadPoolExecutor
-from typing import Deque, Dict, Sequence, Set
+from typing import Deque, Dict, Optional, Sequence, Set
 
-from PyQt5.QtCore import QObject, pyqtProperty, pyqtSlot
+from atomicfile import AtomicFile
+from PyQt5.QtCore import QObject, QStandardPaths, pyqtProperty, pyqtSlot
 
 from .html_filter import HtmlFilter
 from .model import ListModel, ListModelMap
@@ -105,6 +107,27 @@ class Backend(QObject):
                 break
 
 
+    @staticmethod
+    def getPath(kind:            QStandardPaths.StandardLocation,
+                file:            str,
+                initial_content: Optional[str] = None) -> str:
+        relative_path = file.replace("/", os.sep)
+
+        path = QStandardPaths.locate(kind, relative_path)
+        if path:
+            return path
+
+        base_dir = QStandardPaths.writableLocation(kind)
+        path     = f"{base_dir}{os.sep}{relative_path}"
+        os.makedirs(os.path.split(path)[0], exist_ok=True)
+
+        if initial_content is not None:
+            with AtomicFile(path, "w") as new:
+                new.write(initial_content)
+
+        return path
+
+
     @pyqtSlot()
     @pyqtSlot(list)
     def pdb(self, additional_data: Sequence = ()) -> None:
diff --git a/harmonyqml/backend/client_manager.py b/harmonyqml/backend/client_manager.py
index 3e0b26af..d6240e36 100644
--- a/harmonyqml/backend/client_manager.py
+++ b/harmonyqml/backend/client_manager.py
@@ -117,29 +117,8 @@ class ClientManager(QObject, Mapping, metaclass=_ClientManagerMeta):
 
     # Standard file paths
 
-    @staticmethod
-    def _get_standard_path(kind:            QStandardPaths.StandardLocation,
-                           file:            str,
-                           initial_content: Optional[str] = None) -> str:
-        relative_path = file.replace("/", os.sep)
-
-        path = QStandardPaths.locate(kind, relative_path)
-        if path:
-            return path
-
-        base_dir = QStandardPaths.writableLocation(kind)
-        path     = f"{base_dir}{os.sep}{relative_path}"
-        os.makedirs(os.path.split(path)[0], exist_ok=True)
-
-        if initial_content is not None:
-            with AtomicFile(path, "w") as new:
-                new.write(initial_content)
-
-        return path
-
-
     def getAccountConfigPath(self) -> str:
-        return self._get_standard_path(
+        return self.backend.getPath(
             QStandardPaths.AppConfigLocation, "accounts.json", "[]"
         )