Re-add local highlights similar to 0.5.0
This commit is contained in:
parent
aa8dbce3a7
commit
7f66ebb786
@ -283,9 +283,10 @@ class Backend:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
async def update(client: MatrixClient) -> None:
|
async def update(client: MatrixClient) -> None:
|
||||||
room = self.models[client.user_id, "rooms"].get(room_id)
|
room = self.models[client.user_id, "rooms"].get(room_id)
|
||||||
|
local = room.local_unreads or room.local_highlights
|
||||||
|
|
||||||
if room and room.unreads or room.highlights or room.local_unreads:
|
if room and room.unreads or room.highlights or local:
|
||||||
room.unreads = 0
|
room.unreads = 0
|
||||||
room.highlights = 0
|
room.highlights = 0
|
||||||
room.local_unreads = False
|
room.local_unreads = False
|
||||||
|
@ -1342,9 +1342,10 @@ class MatrixClient(nio.AsyncClient):
|
|||||||
async def update_account_unread_counts(self) -> None:
|
async def update_account_unread_counts(self) -> None:
|
||||||
"""Recalculate total unread notifications/highlights for our account"""
|
"""Recalculate total unread notifications/highlights for our account"""
|
||||||
|
|
||||||
local_unreads = False
|
unreads = 0
|
||||||
unreads = 0
|
highlights = 0
|
||||||
highlights = 0
|
local_unreads = False
|
||||||
|
local_highlights = False
|
||||||
|
|
||||||
for room in self.models[self.user_id, "rooms"].values():
|
for room in self.models[self.user_id, "rooms"].values():
|
||||||
unreads += room.unreads
|
unreads += room.unreads
|
||||||
@ -1353,10 +1354,14 @@ class MatrixClient(nio.AsyncClient):
|
|||||||
if room.local_unreads:
|
if room.local_unreads:
|
||||||
local_unreads = True
|
local_unreads = True
|
||||||
|
|
||||||
|
if room.local_highlights:
|
||||||
|
local_highlights = True
|
||||||
|
|
||||||
account = self.models["accounts"][self.user_id]
|
account = self.models["accounts"][self.user_id]
|
||||||
account.total_unread = unreads
|
account.total_unread = unreads
|
||||||
account.total_highlights = highlights
|
account.total_highlights = highlights
|
||||||
account.local_unreads = local_unreads
|
account.local_unreads = local_unreads
|
||||||
|
account.local_highlights = local_highlights
|
||||||
|
|
||||||
|
|
||||||
async def event_is_past(self, ev: Union[nio.Event, Event]) -> bool:
|
async def event_is_past(self, ev: Union[nio.Event, Event]) -> bool:
|
||||||
@ -1405,11 +1410,13 @@ class MatrixClient(nio.AsyncClient):
|
|||||||
last_event_date = datetime.fromtimestamp(0)
|
last_event_date = datetime.fromtimestamp(0)
|
||||||
typing_members = []
|
typing_members = []
|
||||||
local_unreads = False
|
local_unreads = False
|
||||||
|
local_highlights = False
|
||||||
update_account_unread_counts = True
|
update_account_unread_counts = True
|
||||||
else:
|
else:
|
||||||
last_event_date = registered.last_event_date
|
last_event_date = registered.last_event_date
|
||||||
typing_members = registered.typing_members
|
typing_members = registered.typing_members
|
||||||
local_unreads = registered.local_unreads
|
local_unreads = registered.local_unreads
|
||||||
|
local_highlights = registered.local_highlights
|
||||||
update_account_unread_counts = (
|
update_account_unread_counts = (
|
||||||
registered.unreads != room.unread_notifications or
|
registered.unreads != room.unread_notifications or
|
||||||
registered.highlights != room.unread_highlights
|
registered.highlights != room.unread_highlights
|
||||||
@ -1452,9 +1459,10 @@ class MatrixClient(nio.AsyncClient):
|
|||||||
|
|
||||||
last_event_date = last_event_date,
|
last_event_date = last_event_date,
|
||||||
|
|
||||||
unreads = room.unread_notifications,
|
unreads = room.unread_notifications,
|
||||||
highlights = room.unread_highlights,
|
highlights = room.unread_highlights,
|
||||||
local_unreads = local_unreads,
|
local_unreads = local_unreads,
|
||||||
|
local_highlights = local_highlights,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.models[self.user_id, "rooms"][room.room_id] = room_item
|
self.models[self.user_id, "rooms"][room.room_id] = room_item
|
||||||
@ -1632,4 +1640,7 @@ class MatrixClient(nio.AsyncClient):
|
|||||||
room_item = self.models[self.user_id, "rooms"][room.room_id]
|
room_item = self.models[self.user_id, "rooms"][room.room_id]
|
||||||
room_item.local_unreads = True
|
room_item.local_unreads = True
|
||||||
|
|
||||||
|
if mentions_us:
|
||||||
|
room_item.local_highlights = True
|
||||||
|
|
||||||
await self.update_account_unread_counts()
|
await self.update_account_unread_counts()
|
||||||
|
@ -42,6 +42,7 @@ class Account(ModelItem):
|
|||||||
total_unread: int = 0
|
total_unread: int = 0
|
||||||
total_highlights: int = 0
|
total_highlights: int = 0
|
||||||
local_unreads: bool = False
|
local_unreads: bool = False
|
||||||
|
local_highlights: bool = False
|
||||||
|
|
||||||
def __lt__(self, other: "Account") -> bool:
|
def __lt__(self, other: "Account") -> bool:
|
||||||
"""Sort by order, then by user ID."""
|
"""Sort by order, then by user ID."""
|
||||||
@ -85,9 +86,10 @@ class Room(ModelItem):
|
|||||||
|
|
||||||
last_event_date: datetime = ZeroDate
|
last_event_date: datetime = ZeroDate
|
||||||
|
|
||||||
unreads: int = 0
|
unreads: int = 0
|
||||||
highlights: int = 0
|
highlights: int = 0
|
||||||
local_unreads: bool = False
|
local_unreads: bool = False
|
||||||
|
local_highlights: bool = False
|
||||||
|
|
||||||
def __lt__(self, other: "Room") -> bool:
|
def __lt__(self, other: "Room") -> bool:
|
||||||
"""Sort by membership, highlights/unread events, last event date, name.
|
"""Sort by membership, highlights/unread events, last event date, name.
|
||||||
@ -105,6 +107,7 @@ class Room(ModelItem):
|
|||||||
self.left,
|
self.left,
|
||||||
other.inviter_id,
|
other.inviter_id,
|
||||||
bool(other.highlights),
|
bool(other.highlights),
|
||||||
|
bool(other.local_highlights),
|
||||||
bool(other.unreads),
|
bool(other.unreads),
|
||||||
bool(other.local_unreads),
|
bool(other.local_unreads),
|
||||||
other.last_event_date,
|
other.last_event_date,
|
||||||
@ -115,6 +118,7 @@ class Room(ModelItem):
|
|||||||
other.left,
|
other.left,
|
||||||
self.inviter_id,
|
self.inviter_id,
|
||||||
bool(self.highlights),
|
bool(self.highlights),
|
||||||
|
bool(self.local_highlights),
|
||||||
bool(self.unreads),
|
bool(self.unreads),
|
||||||
bool(self.local_unreads),
|
bool(self.local_unreads),
|
||||||
self.last_event_date,
|
self.last_event_date,
|
||||||
@ -135,6 +139,7 @@ class AccountOrRoom(Account, Room):
|
|||||||
self.left,
|
self.left,
|
||||||
other.inviter_id,
|
other.inviter_id,
|
||||||
bool(other.highlights),
|
bool(other.highlights),
|
||||||
|
bool(other.local_highlights),
|
||||||
bool(other.unreads),
|
bool(other.unreads),
|
||||||
bool(other.local_unreads),
|
bool(other.local_unreads),
|
||||||
other.last_event_date,
|
other.last_event_date,
|
||||||
@ -147,6 +152,7 @@ class AccountOrRoom(Account, Room):
|
|||||||
other.left,
|
other.left,
|
||||||
self.inviter_id,
|
self.inviter_id,
|
||||||
bool(self.highlights),
|
bool(self.highlights),
|
||||||
|
bool(self.local_highlights),
|
||||||
bool(self.unreads),
|
bool(self.unreads),
|
||||||
bool(self.local_unreads),
|
bool(self.local_unreads),
|
||||||
self.last_event_date,
|
self.last_event_date,
|
||||||
|
@ -58,6 +58,7 @@ HTile {
|
|||||||
unreads: model.total_unread
|
unreads: model.total_unread
|
||||||
highlights: model.total_highlights
|
highlights: model.total_highlights
|
||||||
localUnreads: model.local_unreads
|
localUnreads: model.local_unreads
|
||||||
|
localHighlights: model.local_highlights
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ HLabel {
|
|||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color:
|
color:
|
||||||
highlights ?
|
highlights || (! unreads && localUnreads && localHighlights) ?
|
||||||
indicatorTheme.mentionBackground :
|
indicatorTheme.mentionBackground :
|
||||||
indicatorTheme.background
|
indicatorTheme.background
|
||||||
|
|
||||||
@ -36,6 +36,7 @@ HLabel {
|
|||||||
property int unreads: 0
|
property int unreads: 0
|
||||||
property int highlights: 0
|
property int highlights: 0
|
||||||
property bool localUnreads: false
|
property bool localUnreads: false
|
||||||
|
property bool localHighlights: false
|
||||||
|
|
||||||
|
|
||||||
Behavior on scale { HNumberAnimation {} }
|
Behavior on scale { HNumberAnimation {} }
|
||||||
|
@ -48,6 +48,7 @@ HTile {
|
|||||||
unreads: model.unreads
|
unreads: model.unreads
|
||||||
highlights: model.highlights
|
highlights: model.highlights
|
||||||
localUnreads: model.local_unreads
|
localUnreads: model.local_unreads
|
||||||
|
localHighlights: model.local_highlights
|
||||||
}
|
}
|
||||||
|
|
||||||
HIcon {
|
HIcon {
|
||||||
|
@ -361,7 +361,8 @@ Rectangle {
|
|||||||
(
|
(
|
||||||
chat.roomInfo.unreads ||
|
chat.roomInfo.unreads ||
|
||||||
chat.roomInfo.highlights ||
|
chat.roomInfo.highlights ||
|
||||||
chat.roomInfo.local_unreads
|
chat.roomInfo.local_unreads ||
|
||||||
|
chat.roomInfo.local_highlights
|
||||||
) &&
|
) &&
|
||||||
Qt.application.state === Qt.ApplicationActive &&
|
Qt.application.state === Qt.ApplicationActive &&
|
||||||
(eventList.contentY + eventList.height) > -50
|
(eventList.contentY + eventList.height) > -50
|
||||||
|
Loading…
x
Reference in New Issue
Block a user