Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

newmail_notifier: favicon notification remove fails #4324

Closed
rcubetrac opened this issue Aug 30, 2013 · 6 comments
Closed

newmail_notifier: favicon notification remove fails #4324

rcubetrac opened this issue Aug 30, 2013 · 6 comments

Comments

@rcubetrac
Copy link

Reported by izbushka on 30 Aug 2013 06:58 UTC as Trac ticket #1489313

Favicon does not change to default on message preview after receiving more than 1 new mail (after 2 or more new mail notifications).

On a second notification rcmail.env.favicon_href variable is assigned a value with the changed icon:

newmail_notifier.js line 50: rcmail.env.favicon_href = oldlink.attr('href');

so function newmail_notifier_stop(prop) revert it to same value (not to default)

Keywords: newmail_notifier favicon
Migrated-From: http://trac.roundcube.net/ticket/1489313

@rcubetrac
Copy link
Author

Comment by izbushka on 30 Aug 2013 07:25 UTC

Here is the patch:

--- newmail_notifier.js.0.9.3   2013-08-30 10:01:03.000000000 +0300
+++ newmail_notifier.js 2013-08-30 10:21:42.000000000 +0300
@@ -9,6 +9,9 @@
     rcmail.addEventListener('plugin.newmail_notifier', newmail_notifier_run);
     rcmail.addEventListener('actionbefore', newmail_notifier_stop);
     rcmail.addEventListener('init', function() {
+   var w = rcmail.is_framed() ? window.parent : window;
+   // Saving default favicon
+   rcmail.env.favicon_default=$('link[icon"](rel="shortcut)', w.document).attr('href');
         // bind to messages list select event, so favicon will be reverted on message preview too
         if (rcmail.message_list)
             rcmail.message_list.addEventListener('select', newmail_notifier_stop);
@@ -31,7 +34,7 @@
 {
     // revert original favicon
     if (rcmail.env.favicon_href && (!prop || prop.action != 'check-recent')) {
-        $('<link rel="shortcut icon" href="'+rcmail.env.favicon_href+'"/>').replaceAll('link[icon"](rel="shortcut)');
+        $('<link rel="shortcut icon" href="'+rcmail.env.favicon_default+'"/>').replaceAll('link[icon"](rel="shortcut)');
         rcmail.env.favicon_href = null;
     }
 }

@rcubetrac
Copy link
Author

Comment by izbushka on 30 Aug 2013 08:03 UTC

Here is a better patch implementation.
It does not change favicon if it's already changed.

--- newmail_notifier.js.0.9.3   2013-08-30 10:01:03.000000000 +0300
+++ newmail_notifier.js 2013-08-30 10:58:21.000000000 +0300
@@ -42,13 +42,13 @@
     var w = rcmail.is_framed() ? window.parent : window;

     w.focus();
-
-    // we cannot simply change a href attribute, we must to replace the link element (at least in FF)
-    var link = $('<link rel="shortcut icon" href="plugins/newmail_notifier/favicon.ico"/>'),
-        oldlink = $('link[icon"](rel="shortcut)', w.document);
-
-    rcmail.env.favicon_href = oldlink.attr('href');
-    link.replaceAll(oldlink);
+   if(!rcmail.env.favicon_href) {
+       // we cannot simply change a href attribute, we must to replace the link element (at least in FF)
+       var link = $('<link rel="shortcut icon" href="plugins/newmail_notifier/favicon.ico"/>'),
+           oldlink = $('link[icon"](rel="shortcut)', w.document);
+       rcmail.env.favicon_href = oldlink.attr('href');
+       link.replaceAll(oldlink);
+   }
 }

 // Sound notification

@rcubetrac
Copy link
Author

Comment by @alecpl on 30 Aug 2013 08:27 UTC

Confirmed.

@rcubetrac
Copy link
Author

Milestone changed by @alecpl on 30 Aug 2013 08:27 UTC

later => 0.9.4

@rcubetrac
Copy link
Author

Comment by @alecpl on 30 Aug 2013 08:40 UTC

Fixed in c9e1e38.

@rcubetrac
Copy link
Author

Status changed by @alecpl on 30 Aug 2013 08:40 UTC

new => closed

@rcubetrac rcubetrac added this to the 0.9.4 milestone Mar 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant