Show max file size on upload button tooltip
This commit is contained in:
parent
ca8dd65f34
commit
61cc87cf18
2
TODO.md
2
TODO.md
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
- "exception during sync" aren't caught
|
- "exception during sync" aren't caught
|
||||||
- nio ClientTimeout
|
- nio ClientTimeout
|
||||||
- Handle upload file size limit
|
- Name
|
||||||
- Update docstrings
|
- Update docstrings
|
||||||
- Update TODO.md
|
- Update TODO.md
|
||||||
- Update README.md
|
- Update README.md
|
||||||
|
|
|
@ -110,9 +110,10 @@ class MatrixClient(nio.AsyncClient):
|
||||||
self.backend: "Backend" = backend
|
self.backend: "Backend" = backend
|
||||||
self.models: ModelStore = self.backend.models
|
self.models: ModelStore = self.backend.models
|
||||||
|
|
||||||
self.profile_task: Optional[asyncio.Future] = None
|
self.profile_task: Optional[asyncio.Future] = None
|
||||||
self.sync_task: Optional[asyncio.Future] = None
|
self.server_config_task: Optional[asyncio.Future] = None
|
||||||
self.load_rooms_task: Optional[asyncio.Future] = None
|
self.sync_task: Optional[asyncio.Future] = None
|
||||||
|
self.load_rooms_task: Optional[asyncio.Future] = None
|
||||||
|
|
||||||
self.upload_monitors: Dict[UUID, nio.TransferMonitor] = {}
|
self.upload_monitors: Dict[UUID, nio.TransferMonitor] = {}
|
||||||
|
|
||||||
|
@ -179,7 +180,12 @@ class MatrixClient(nio.AsyncClient):
|
||||||
async def logout(self) -> None:
|
async def logout(self) -> None:
|
||||||
"""Logout from the server. This will delete the device."""
|
"""Logout from the server. This will delete the device."""
|
||||||
|
|
||||||
for task in (self.profile_task, self.load_rooms_task, self.sync_task):
|
tasks = (
|
||||||
|
self.profile_task, self.load_rooms_task, self.sync_task,
|
||||||
|
self.server_config_task,
|
||||||
|
)
|
||||||
|
|
||||||
|
for task in tasks:
|
||||||
if task:
|
if task:
|
||||||
task.cancel()
|
task.cancel()
|
||||||
with suppress(asyncio.CancelledError):
|
with suppress(asyncio.CancelledError):
|
||||||
|
@ -221,11 +227,34 @@ class MatrixClient(nio.AsyncClient):
|
||||||
account.display_name = resp.displayname or ""
|
account.display_name = resp.displayname or ""
|
||||||
account.avatar_url = resp.avatar_url or ""
|
account.avatar_url = resp.avatar_url or ""
|
||||||
|
|
||||||
|
def on_server_config_response(future) -> None:
|
||||||
|
"""Update our model `Account` with the received config details."""
|
||||||
|
|
||||||
|
exception = future.exception()
|
||||||
|
|
||||||
|
if exception:
|
||||||
|
log.warn("On %s client startup: %r", self.user_id, exception)
|
||||||
|
self.server_config_task = asyncio.ensure_future(
|
||||||
|
self.get_server_config(),
|
||||||
|
)
|
||||||
|
self.server_config_task.add_done_callback(
|
||||||
|
on_server_config_response,
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
account = self.models["accounts"][self.user_id]
|
||||||
|
account.max_upload_size = future.result()
|
||||||
|
|
||||||
self.profile_task = asyncio.ensure_future(
|
self.profile_task = asyncio.ensure_future(
|
||||||
self.backend.get_profile(self.user_id),
|
self.backend.get_profile(self.user_id),
|
||||||
)
|
)
|
||||||
self.profile_task.add_done_callback(on_profile_response)
|
self.profile_task.add_done_callback(on_profile_response)
|
||||||
|
|
||||||
|
self.server_config_task = asyncio.ensure_future(
|
||||||
|
self.get_server_config(),
|
||||||
|
)
|
||||||
|
self.server_config_task.add_done_callback(on_server_config_response)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
self.sync_task = asyncio.ensure_future(
|
self.sync_task = asyncio.ensure_future(
|
||||||
|
@ -239,6 +268,11 @@ class MatrixClient(nio.AsyncClient):
|
||||||
await asyncio.sleep(2)
|
await asyncio.sleep(2)
|
||||||
|
|
||||||
|
|
||||||
|
async def get_server_config(self) -> int:
|
||||||
|
"""Return the maximum upload size on this server"""
|
||||||
|
return (await self.content_repository_config()).upload_size
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def all_rooms(self) -> Dict[str, nio.MatrixRoom]:
|
def all_rooms(self) -> Dict[str, nio.MatrixRoom]:
|
||||||
"""Return dict containing both our joined and invited rooms."""
|
"""Return dict containing both our joined and invited rooms."""
|
||||||
|
|
|
@ -35,8 +35,9 @@ class Account(ModelItem):
|
||||||
id: str = field()
|
id: str = field()
|
||||||
display_name: str = ""
|
display_name: str = ""
|
||||||
avatar_url: str = ""
|
avatar_url: str = ""
|
||||||
first_sync_done: bool = False
|
max_upload_size: int = 0
|
||||||
profile_updated: datetime = ZeroDate
|
profile_updated: datetime = ZeroDate
|
||||||
|
first_sync_done: bool = False
|
||||||
|
|
||||||
def __lt__(self, other: "Account") -> bool:
|
def __lt__(self, other: "Account") -> bool:
|
||||||
"""Sort by display name or user ID."""
|
"""Sort by display name or user ID."""
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import QtQuick.Layouts 1.12
|
import QtQuick.Layouts 1.12
|
||||||
import Clipboard 0.1
|
import Clipboard 0.1
|
||||||
|
import CppUtils 0.1
|
||||||
import "../.."
|
import "../.."
|
||||||
import "../../Base"
|
import "../../Base"
|
||||||
import "../../Dialogs"
|
import "../../Dialogs"
|
||||||
|
@ -218,7 +219,13 @@ Rectangle {
|
||||||
enabled: chat.roomInfo.can_send_messages
|
enabled: chat.roomInfo.can_send_messages
|
||||||
icon.name: "upload-file"
|
icon.name: "upload-file"
|
||||||
backgroundColor: theme.chat.composer.uploadButton.background
|
backgroundColor: theme.chat.composer.uploadButton.background
|
||||||
toolTip.text: qsTr("Send files")
|
toolTip.text:
|
||||||
|
chat.userInfo.max_upload_size ?
|
||||||
|
qsTr("Send files (%1 max)").arg(
|
||||||
|
CppUtils.formattedBytes(chat.userInfo.max_upload_size, 0),
|
||||||
|
) :
|
||||||
|
qsTr("Send files")
|
||||||
|
|
||||||
onClicked: sendFilePicker.dialog.open()
|
onClicked: sendFilePicker.dialog.open()
|
||||||
|
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
|
|
Loading…
Reference in New Issue
Block a user