Mercurial > snowl
changeset 10:64defcf896f1
update the list of sources when the user subscribes to one
author | Myk Melez <myk@mozilla.org> |
---|---|
date | Fri, 11 Apr 2008 15:07:21 -0700 |
parents | d8abd85fc94d |
children | 40c49a0e9e34 |
files | extension/content/sidebar.js extension/content/subscribe.js |
diffstat | 2 files changed, 37 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/extension/content/sidebar.js Fri Apr 11 14:24:54 2008 -0700 +++ b/extension/content/sidebar.js Fri Apr 11 15:07:21 2008 -0700 @@ -6,6 +6,15 @@ getInterface(Ci.nsIDOMWindow); SourcesView = { + // Observer Service + get _obsSvc() { + let obsSvc = Cc["@mozilla.org/observer-service;1"]. + getService(Ci.nsIObserverService); + delete this._obsSvc; + this._obsSvc = obsSvc; + return this._obsSvc; + }, + get _tree() { let tree = document.getElementById("sourcesView"); delete this._tree; @@ -21,6 +30,33 @@ }, init: function() { + this._obsSvc.addObserver(this, "sources:changed", true); + this._rebuildView(); + }, + + //**************************************************************************// + // XPCOM Interface Implementations + + // nsISupports + QueryInterface: function(aIID) { + if (aIID.equals(Ci.nsIObserver) || + aIID.equals(Ci.nsISupportsWeakReference) || + aIID.equals(Ci.nsISupports)) + return this; + + throw Cr.NS_ERROR_NO_INTERFACE; + }, + + // nsIObserver + observe: function(subject, topic, data) { + switch (topic) { + case "sources:changed": + this._rebuildView(); + break; + } + }, + + _rebuildView: function() { let statementString = "SELECT title, id FROM sources ORDER BY title"; let statement = SnowlDatastore.createStatement(statementString);
--- a/extension/content/subscribe.js Fri Apr 11 14:24:54 2008 -0700 +++ b/extension/content/subscribe.js Fri Apr 11 15:07:21 2008 -0700 @@ -130,6 +130,7 @@ } this._appendMessage("You have been subscribed to '" + feed.title.plainText() + "'."); + this._obsSvc.notifyObservers(null, "sources:changed", null); this._obsSvc.notifyObservers(null, "messages:changed", null); },