From 15da828c70e723f103c1e069f8319a2441ad832a Mon Sep 17 00:00:00 2001 From: miruka Date: Mon, 6 May 2019 22:42:48 -0400 Subject: [PATCH] Pass a store dir path to nio HttpClient --- TODO.md | 1 + harmonyqml/backend/client.py | 18 +++++++++++++----- harmonyqml/components/Chat/SendBox.qml | 1 - 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/TODO.md b/TODO.md index b2620334..488e7ed9 100644 --- a/TODO.md +++ b/TODO.md @@ -4,6 +4,7 @@ - Cleanup unused icons - Bug fixes + - Something weird happening when nio store is created first time - 100% CPU usage when hitting top edge to trigger messages loading - Sending `![A picture](https://picsum.photos/256/256)` → not clickable? - Icons, images and HStyle singleton aren't reloaded diff --git a/harmonyqml/backend/client.py b/harmonyqml/backend/client.py index 24e74e2f..82a2611c 100644 --- a/harmonyqml/backend/client.py +++ b/harmonyqml/backend/client.py @@ -6,7 +6,9 @@ from concurrent.futures import ThreadPoolExecutor from threading import Event from typing import DefaultDict, Tuple -from PyQt5.QtCore import QObject, pyqtProperty, pyqtSignal, pyqtSlot +from PyQt5.QtCore import ( + QObject, QStandardPaths, pyqtProperty, pyqtSignal, pyqtSlot +) import nio @@ -43,13 +45,19 @@ class Client(QObject): self.pool: ThreadPoolExecutor = ThreadPoolExecutor(6) - self.nio: nio.client.HttpClient = \ - nio.client.HttpClient(self.host, username, device_id) + store_path = self.manager.backend.getDir( + QStandardPaths.AppDataLocation + ) + + self.nio: nio.client.HttpClient = nio.client.HttpClient( + self.host, username, device_id, store_path=store_path + ) # Since nio clients can't handle more than one talk operation # at a time, this one is used exclusively to poll the sync API - self.nio_sync: nio.client.HttpClient = \ - nio.client.HttpClient(self.host, username, device_id) + self.nio_sync: nio.client.HttpClient = nio.client.HttpClient( + self.host, username, device_id, store_path=store_path + ) self.net = NetworkManager(self.host, self.port, self.nio) self.net_sync = NetworkManager(self.host, self.port, self.nio_sync) diff --git a/harmonyqml/components/Chat/SendBox.qml b/harmonyqml/components/Chat/SendBox.qml index 7b33bd1d..2978870a 100644 --- a/harmonyqml/components/Chat/SendBox.qml +++ b/harmonyqml/components/Chat/SendBox.qml @@ -40,7 +40,6 @@ HGlassRectangle { area.onEditingFinished: setTyping(false) // when lost focus Keys.onReturnPressed: { - console.log( "enter") event.accepted = true if (event.modifiers & Qt.ShiftModifier ||