Remove pointless local_highlights

An event can only be considered a highlight if a push rule make it so,
thus an event can never be locally highlighted only.
This commit is contained in:
miruka 2020-11-03 06:43:30 -04:00
parent 35a8c0aec4
commit 2ef1edb3dc
8 changed files with 21 additions and 46 deletions

View File

@ -379,10 +379,9 @@ class Backend:
if room: if room:
room.set_fields( room.set_fields(
unreads = 0, unreads = 0,
highlights = 0, highlights = 0,
local_unreads = False, local_unreads = False,
local_highlights = False,
) )
await client.update_account_unread_counts() await client.update_account_unread_counts()

View File

@ -1833,10 +1833,9 @@ 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"""
unreads = 0 unreads = 0
highlights = 0 highlights = 0
local_unreads = False 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
@ -1845,15 +1844,11 @@ 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.set_fields( account.set_fields(
total_unread = unreads, total_unread = unreads,
total_highlights = highlights, total_highlights = highlights,
local_unreads = local_unreads, local_unreads = local_unreads,
local_highlights = local_highlights,
) )
@ -1903,7 +1898,6 @@ 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
unverified_devices = ( unverified_devices = (
False False
@ -1914,7 +1908,6 @@ class MatrixClient(nio.AsyncClient):
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
@ -1962,10 +1955,9 @@ 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,
lexical_sorting = self.backend.settings.RoomList.lexical_sort, lexical_sorting = self.backend.settings.RoomList.lexical_sort,
bookmarked = room.room_id in bookmarks.get(self.user_id, []), bookmarked = room.room_id in bookmarks.get(self.user_id, []),
@ -2272,10 +2264,7 @@ class MatrixClient(nio.AsyncClient):
self.previous_server_unreads[room.room_id] = room_item.unreads self.previous_server_unreads[room.room_id] = room_item.unreads
self.previous_server_highlights[room.room_id] = room_item.highlights self.previous_server_highlights[room.room_id] = room_item.highlights
if highlight: room_item.local_unreads = True
room_item.set_fields(local_unreads=True, local_highlights=True)
else:
room_item.local_unreads = True
if unread or highlight: if unread or highlight:
members = self.models[self.user_id, room.room_id, "members"] members = self.models[self.user_id, room.room_id, "members"]

View File

@ -69,7 +69,6 @@ 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
# For some reason, Account cannot inherit Presence, because QML keeps # For some reason, Account cannot inherit Presence, because QML keeps
# complaining type error on unknown file # complaining type error on unknown file
@ -165,10 +164,9 @@ class Room(ModelItem):
last_event_date: datetime = ZERO_DATE last_event_date: datetime = ZERO_DATE
unreads: int = 0 unreads: int = 0
highlights: int = 0 highlights: int = 0
local_unreads: bool = False local_unreads: bool = False
local_highlights: bool = False
lexical_sorting: bool = False lexical_sorting: bool = False
bookmarked: bool = False bookmarked: bool = False
@ -207,7 +205,6 @@ class Room(ModelItem):
self.left, self.left,
bool(other.inviter_id), bool(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,
@ -220,7 +217,6 @@ class Room(ModelItem):
other.left, other.left,
bool(self.inviter_id), bool(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,
@ -264,7 +260,6 @@ class AccountOrRoom(Account, Room):
self.left, self.left,
bool(other.inviter_id), bool(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,
@ -279,7 +274,6 @@ class AccountOrRoom(Account, Room):
other.left, other.left,
bool(self.inviter_id), bool(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,

View File

@ -98,7 +98,6 @@ 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
} }
} }

View File

@ -11,10 +11,6 @@ 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
readonly property bool useHighlightStyle:
highlights || (! unreads && localUnreads && localHighlights)
text: text:
@ -25,13 +21,13 @@ HLabel {
"" ""
color: color:
useHighlightStyle ? highlights ?
indicatorTheme.highlightText : indicatorTheme.highlightText :
indicatorTheme.text indicatorTheme.text
font.pixelSize: theme.fontSize.small font.pixelSize: theme.fontSize.small
font.bold: font.bold:
useHighlightStyle ? highlights ?
indicatorTheme.highlightBold : indicatorTheme.highlightBold :
indicatorTheme.bold indicatorTheme.bold
@ -44,22 +40,22 @@ HLabel {
background: Rectangle { background: Rectangle {
radius: radius:
useHighlightStyle ? highlights ?
indicatorTheme.highlightRadius : indicatorTheme.highlightRadius :
indicatorTheme.radius indicatorTheme.radius
color: color:
useHighlightStyle ? highlights ?
indicatorTheme.highlightBackground : indicatorTheme.highlightBackground :
indicatorTheme.background indicatorTheme.background
border.width: border.width:
useHighlightStyle ? highlights ?
indicatorTheme.highlightBorderWidth : indicatorTheme.highlightBorderWidth :
indicatorTheme.borderWidth indicatorTheme.borderWidth
border.color: border.color:
useHighlightStyle ? highlights ?
indicatorTheme.highlightBorder : indicatorTheme.highlightBorder :
indicatorTheme.border indicatorTheme.border

View File

@ -77,7 +77,6 @@ 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 {

View File

@ -93,7 +93,7 @@ HListView {
function cycleUnreadRooms(forward=true, highlights=false) { function cycleUnreadRooms(forward=true, highlights=false) {
const prop = highlights ? "highlights" : "unreads" const prop = highlights ? "highlights" : "unreads"
const local_prop = highlights ? "local_highlights" : "local_unreads" const local_prop = highlights ? "highlights" : "local_unreads"
const start = currentIndex === -1 ? 0 : currentIndex const start = currentIndex === -1 ? 0 : currentIndex
let index = start let index = start

View File

@ -627,8 +627,7 @@ 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.visibleEnd.y > eventList.contentHeight - 100 eventList.visibleEnd.y > eventList.contentHeight - 100