Closed Bug 779136 Opened 12 years ago Closed 12 years ago

Make Chat button turn blue if any new unread messages exist

Categories

(Thunderbird :: Instant Messaging, defect)

15 Branch
x86
All
defect
Not set
normal

Tracking

(thunderbird15+ fixed, thunderbird16+ fixed)

RESOLVED FIXED
Thunderbird 17.0
Tracking Status
thunderbird15 + fixed
thunderbird16 + fixed

People

(Reporter: mconley, Assigned: mconley)

Details

Attachments

(1 file, 3 obsolete files)

The current behaviour of the Chat button in the 3pane is that it turns blue and shows a numeric badge when there are any "mentions" in any chat conversation.

What we'd like is for the icon to turn blue if there is any new activity in any conversation, and show the numeric badge if there are any mentions.
Assignee: nobody → mconley
I think you just need to change http://hg.mozilla.org/comm-central/annotate/b3a09c3b06c9/mail/components/im/content/chat-messenger-overlay.js#l283 to return 2 values instead of one, and use one value for whether the icon turn blue, and the other (existing) one for the badge count.
This is somehow related to bug 745369 that requested a notification for new messages that aren't directed to the user.
Attached patch WIP Patch 1 (obsolete) — Splinter Review
Checkpointing while I transfer to Windows machine, but I think I more or less have this done.
Comment on attachment 647617 [details] [diff] [review]
WIP Patch 1

Review of attachment 647617 [details] [diff] [review]:
-----------------------------------------------------------------

Is this the right idea?
Attachment #647617 - Flags: ui-review?(bwinton)
Comment on attachment 647617 [details] [diff] [review]
WIP Patch 1

Review of attachment 647617 [details] [diff] [review]:
-----------------------------------------------------------------

Drive by...

::: mail/components/im/content/chat-messenger-overlay.js
@@ +275,5 @@
> +
> +    if (unreadTotalCount)
> +      chatButton.setAttribute('unreadMessages', 'true');
> +    else
> +      chatButton.removeAttribute('unreadMessages');

Any reason for using single quotes rather than double quotes like everywhere else?

@@ +294,3 @@
>      for each (let conv in convs) {
> +        unreadTargettedCount += conv.unreadTargetedMessageCount;
> +        unreadTotalCount += conv.unreadIncomingMessageCount;

Fix the indent here.

@@ +305,5 @@
>      let title =
>        document.getElementById("chatBundle").getString("chatTabTitle");
> +    let [unreadTargettedCount, unreadTotalCount] = this.countUnreadMessages();
> +    if (unreadTotalCount)
> +      title += " (" + unreadTotalCount + ")";

Is there a reason for displaying the total count instead of the targetted count in the tab title? Wouldn't it be confusing to have a different count displayed in the icon badge and in the tab title?
(In reply to Florian Quèze from comment #5)
> Comment on attachment 647617 [details] [diff] [review]
> WIP Patch 1
> 
> Review of attachment 647617 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> Drive by...
> 
> ::: mail/components/im/content/chat-messenger-overlay.js
> @@ +275,5 @@
> > +
> > +    if (unreadTotalCount)
> > +      chatButton.setAttribute('unreadMessages', 'true');
> > +    else
> > +      chatButton.removeAttribute('unreadMessages');
> 
> Any reason for using single quotes rather than double quotes like everywhere
> else?

Hm - that's a habit I picked up when submitting patches to Gaia (https://wiki.mozilla.org/Gaia#Coding_Style), but having refreshed myself of the Mozilla JS style guide on literals (https://developer.mozilla.org/en/Developer_Guide/Coding_Style#Literals), I'll switch them back to double-quotes.

Good catch!

> 
> @@ +294,3 @@
> >      for each (let conv in convs) {
> > +        unreadTargettedCount += conv.unreadTargetedMessageCount;
> > +        unreadTotalCount += conv.unreadIncomingMessageCount;
> 
> Fix the indent here.
> 
> @@ +305,5 @@
> >      let title =
> >        document.getElementById("chatBundle").getString("chatTabTitle");
> > +    let [unreadTargettedCount, unreadTotalCount] = this.countUnreadMessages();
> > +    if (unreadTotalCount)
> > +      title += " (" + unreadTotalCount + ")";
> 
> Is there a reason for displaying the total count instead of the targetted
> count in the tab title? Wouldn't it be confusing to have a different count
> displayed in the icon badge and in the tab title?

Whoops - you're right, thanks!
Attached patch Patch v1 (obsolete) — Splinter Review
Attachment #647617 - Attachment is obsolete: true
Attachment #647617 - Flags: ui-review?(bwinton)
Attachment #647952 - Flags: ui-review?(bwinton)
Attachment #647952 - Flags: review?(florian)
Attached patch Patch v1 (obsolete) — Splinter Review
As Florian pointed out in IRC, I attached the same WIP patch before. Here's the actual Patch v1.
Attachment #647952 - Attachment is obsolete: true
Attachment #647952 - Flags: ui-review?(bwinton)
Attachment #647952 - Flags: review?(florian)
Attachment #647956 - Flags: ui-review?(bwinton)
Attachment #647956 - Flags: review?(florian)
Comment on attachment 647956 [details] [diff] [review]
Patch v1

Review of attachment 647956 [details] [diff] [review]:
-----------------------------------------------------------------

::: mail/components/im/content/chat-messenger-overlay.js
@@ +282,5 @@
>        let unreadInt = Components.classes["@mozilla.org/supports-PRInt32;1"]
>                                  .createInstance(Ci.nsISupportsPRInt32);
> +      unreadInt.data = unreadTotalCount;
> +      Services.obs.notifyObservers(unreadInt, "unread-im-count-changed", unreadTotalCount);
> +      this._notifiedUnreadCount = unreadTotalCount;

I think you also wanted to use the unreadTargettedCount value for these 6 lines of code related to the unread-im-count-changed notification (the value sent by that notification is directly used by nsMessengerOSXIntegration.mm to badge the dock on Mac).

@@ +303,5 @@
>        return;
>  
>      let title =
>        document.getElementById("chatBundle").getString("chatTabTitle");
> +    let [unreadTargettedCount, unreadTotalCount] = this.countUnreadMessages();

The unreadTotalCount variable seems unused. I think when using a destructuring assignment you only need to name what you use, so this would also work:
let [unreadTargettedCount] = this.countUnreadMessages();
Attachment #647956 - Flags: review?(florian) → review-
Attached patch Patch v2Splinter Review
Attachment #647956 - Attachment is obsolete: true
Attachment #647956 - Flags: ui-review?(bwinton)
Attachment #647979 - Flags: ui-review?(bwinton)
Attachment #647979 - Flags: review?(florian)
Comment on attachment 647979 [details] [diff] [review]
Patch v2

Looks good (note: I haven't tested this). Thanks.
Attachment #647979 - Flags: review?(florian) → review+
Comment on attachment 647979 [details] [diff] [review]
Patch v2

Yes, this.  ui-r=me.
Attachment #647979 - Flags: ui-review?(bwinton) → ui-review+
Attachment #647979 - Flags: approval-comm-beta?
Attachment #647979 - Flags: approval-comm-aurora?
comm-central: https://hg.mozilla.org/comm-central/rev/2af3a435cade
Status: NEW → RESOLVED
Closed: 12 years ago
OS: Windows 7 → All
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 17.0
Attachment #647979 - Flags: approval-comm-beta?
Attachment #647979 - Flags: approval-comm-beta+
Attachment #647979 - Flags: approval-comm-aurora?
Attachment #647979 - Flags: approval-comm-aurora+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: