Inconsistent message read status on Chans tab #1044

Closed
opened 2017-09-05 15:39:27 +02:00 by g1itch · 4 comments
g1itch commented 2017-09-05 15:39:27 +02:00 (Migrated from github.com)

Hello.

When I read the message received from chan in All accounts -> inbox on tab Messages and then switch to Chans tab I see that message still drawn with bold font, like unread.

Hello. When I read the message received from chan in All accounts -> inbox on tab Messages and then switch to Chans tab I see that message still drawn with bold font, like unread.
g1itch commented 2018-01-26 12:06:48 +01:00 (Migrated from github.com)

It's weird: method propagateUnreadCount not uses any of it's four keyword parameters (address=None, folder="inbox", widget=None, type=1). But in method tableWidgetInboxItemClicked it called like this:

            if propagate:
                self.propagateUnreadCount(
                    tableWidget.item(
                        currentRow,
                        1 if tableWidget.item(currentRow, 1).type ==
                        AccountMixin.SUBSCRIPTION else 0
                    ).data(Qt.UserRole),
                    folder, self.getCurrentTreeWidget(), -1
                )
It's weird: method `propagateUnreadCount` not uses any of it's four keyword parameters (`address=None, folder="inbox", widget=None, type=1`). But in method `tableWidgetInboxItemClicked` it called like this: ```python if propagate: self.propagateUnreadCount( tableWidget.item( currentRow, 1 if tableWidget.item(currentRow, 1).type == AccountMixin.SUBSCRIPTION else 0 ).data(Qt.UserRole), folder, self.getCurrentTreeWidget(), -1 ) ```
PeterSurda commented 2018-01-26 12:08:53 +01:00 (Migrated from github.com)

As far as I remember, the arguments were used in the past for performance optimisation, but it lead to problems and the performance difference was very small. It probably needs to be looked at in a bit more detail.

As far as I remember, the arguments were used in the past for performance optimisation, but it lead to problems and the performance difference was very small. It probably needs to be looked at in a bit more detail.
g1itch commented 2018-01-29 09:58:49 +01:00 (Migrated from github.com)

Here's the method tableWidgetInboxItemClicked how it looks for me:

    def tableWidgetInboxItemClicked(self):
        folder = self.getCurrentFolder()
        messageTextedit = self.getCurrentMessageTextedit()
        if not messageTextedit:
            return

        msgid = self.getCurrentMessageId()
        if msgid:
            queryreturn = sqlQuery(
                '''SELECT message FROM %s WHERE msgid=?''' % (
                    'sent' if folder == 'sent' else 'inbox'
                ), msgid
            )

        try:
            message = queryreturn[-1][0]
        except NameError:
            message = ""
        except IndexError:
            message = "Error occurred: could not load message from disk."
        else:
            tableWidget = self.getCurrentMessagelist()
            currentRow = tableWidget.currentRow()
            # refresh
            if tableWidget.item(currentRow, 0).unread is True:
                font = QtGui.QFont()
                font.setBold(False)
                tableWidget.item(currentRow, 0).setUnread(False)
                tableWidget.item(currentRow, 1).setUnread(False)
                tableWidget.item(currentRow, 2).setUnread(False)
                tableWidget.item(currentRow, 3).setFont(font)
            # propagate
            if folder != 'sent' and sqlExecute(
                '''UPDATE inbox SET read=1 WHERE msgid=? AND read=0''',
                msgid
            ) > 0:
                # some refresh call is needed here <<<
                self.propagateUnreadCount()

        messageTextedit.setCurrentFont(QtGui.QFont())
        messageTextedit.setTextColor(QtGui.QColor())
        messageTextedit.setContent(message)
Here's the method [`tableWidgetInboxItemClicked`](../blob/master/src/bitmessageqt/__init__.py#L3825) how it looks for me: ```python def tableWidgetInboxItemClicked(self): folder = self.getCurrentFolder() messageTextedit = self.getCurrentMessageTextedit() if not messageTextedit: return msgid = self.getCurrentMessageId() if msgid: queryreturn = sqlQuery( '''SELECT message FROM %s WHERE msgid=?''' % ( 'sent' if folder == 'sent' else 'inbox' ), msgid ) try: message = queryreturn[-1][0] except NameError: message = "" except IndexError: message = "Error occurred: could not load message from disk." else: tableWidget = self.getCurrentMessagelist() currentRow = tableWidget.currentRow() # refresh if tableWidget.item(currentRow, 0).unread is True: font = QtGui.QFont() font.setBold(False) tableWidget.item(currentRow, 0).setUnread(False) tableWidget.item(currentRow, 1).setUnread(False) tableWidget.item(currentRow, 2).setUnread(False) tableWidget.item(currentRow, 3).setFont(font) # propagate if folder != 'sent' and sqlExecute( '''UPDATE inbox SET read=1 WHERE msgid=? AND read=0''', msgid ) > 0: # some refresh call is needed here <<< self.propagateUnreadCount() messageTextedit.setCurrentFont(QtGui.QFont()) messageTextedit.setTextColor(QtGui.QColor()) messageTextedit.setContent(message) ```
g1itch commented 2018-02-06 15:10:21 +01:00 (Migrated from github.com)

I noticed that this issue is a duplicate of #884

I noticed that this issue is a duplicate of #884
This repo is archived. You cannot comment on issues.
No Milestone
No project
No Assignees
1 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Bitmessage/PyBitmessage-2024-12-02#1044
No description provided.