зеркало из https://github.com/mozilla/snowl.git
implement Undo for feed auto-subscription
--HG-- extra : rebase_source : 08aa4251affda8e26a09829b2328770ffaee6525
This commit is contained in:
Родитель
6336f0084f
Коммит
4b684b81c5
|
@ -585,6 +585,7 @@ this._log.info("removeSource: Removing source - " + query.queryName + " : " + se
|
|||
sourceID = selectedSourceNodesIDs[i][1];
|
||||
SnowlDatastore.dbConnection.beginTransaction();
|
||||
try {
|
||||
// FIXME: refactor this with SnowlSource::unstore.
|
||||
// Delete messages
|
||||
SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM partsText " +
|
||||
"WHERE docid IN " +
|
||||
|
@ -615,6 +616,7 @@ this._log.info("removeSource: Removing source - " + query.queryName + " : " + se
|
|||
//this._log.info("removeSource: Delete Places DONE");
|
||||
|
||||
SnowlDatastore.dbConnection.commitTransaction();
|
||||
Observers.notify("snowl:source:unstored", sourceID);
|
||||
}
|
||||
catch(ex) {
|
||||
SnowlDatastore.dbConnection.rollbackTransaction();
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
oncommand="this.parentNode.parentNode._doButtonCommand(event);">
|
||||
<xul:image anonid="messageImage" class="messageImage" xbl:inherits="src=image"/>
|
||||
<xul:description anonid="messageText" class="messageText" flex="1" xbl:inherits="xbl:text=label"/>
|
||||
<!-- FIXME: localize it. -->
|
||||
<xul:button label="Undo" anonid="undoButton" oncommand="document.getBindingParent(this).undo()"/>
|
||||
<xul:description anonid="subscribeUsingDescription"/>
|
||||
<xul:menulist anonid="handlersMenuList" aria-labelledby="subscribeUsingDescription">
|
||||
<xul:menupopup menugenerated="true" anonid="handlersMenuPopup">
|
||||
|
@ -50,6 +52,11 @@
|
|||
</content>
|
||||
|
||||
<implementation>
|
||||
<constructor>
|
||||
Cu.import("resource://snowl/modules/FeedWriter.js");
|
||||
this._feedWriter = new FeedWriter();
|
||||
</constructor>
|
||||
|
||||
<method name="init">
|
||||
<parameter name="feed"/>
|
||||
<!-- The window into which the Snowl river view has been loaded,
|
||||
|
@ -74,10 +81,12 @@
|
|||
]]></body>
|
||||
</method>
|
||||
|
||||
<constructor>
|
||||
Cu.import("resource://snowl/modules/FeedWriter.js");
|
||||
this._feedWriter = new FeedWriter();
|
||||
</constructor>
|
||||
<method name="undo">
|
||||
<body><![CDATA[
|
||||
this._feed.unstore();
|
||||
this.close();
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
</implementation>
|
||||
</binding>
|
||||
|
|
|
@ -828,6 +828,7 @@ let Sources = {
|
|||
|
||||
onLoad: function() {
|
||||
this._rebuild();
|
||||
Observers.add("snowl:source:unstored", this.onSourceUnstored, this);
|
||||
},
|
||||
|
||||
onSelect: function(event) {
|
||||
|
@ -867,6 +868,25 @@ let Sources = {
|
|||
SnowlMessageView._rebuildView();
|
||||
},
|
||||
|
||||
onSourceUnstored: function(sourceID) {
|
||||
this._log.info("onSourceUnstored: " + sourceID);
|
||||
|
||||
for (let i = 0; i < this._list.itemCount; i++) {
|
||||
let item = this._list.getItemAtIndex(i);
|
||||
if (item.source && item.source.id == sourceID) {
|
||||
let selected = item.selected;
|
||||
this._list.removeItemAt(i);
|
||||
if (selected) {
|
||||
// FIXME: rebuild the collection based on other selected sources
|
||||
// once multiple selection is enabled.
|
||||
SnowlMessageView._collection = [];
|
||||
SnowlMessageView._rebuildView();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
//**************************************************************************//
|
||||
// View Construction
|
||||
|
|
|
@ -444,6 +444,45 @@ this._log.info("persist placeID:sources.id - " + this.placeID + " : " + this.id)
|
|||
Observers.notify("snowl:messages:changed", this.id);
|
||||
}),
|
||||
|
||||
unstore: function() {
|
||||
SnowlDatastore.dbConnection.beginTransaction();
|
||||
try {
|
||||
// FIXME: delegate unstorage of messages and people to their respective
|
||||
// JavaScript representations.
|
||||
SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM partsText " +
|
||||
"WHERE docid IN " +
|
||||
"(SELECT id FROM parts WHERE messageID IN " +
|
||||
"(SELECT id FROM messages WHERE sourceID = " + this.id + "))");
|
||||
SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM parts " +
|
||||
"WHERE messageID IN " +
|
||||
"(SELECT id FROM messages WHERE sourceID = " + this.id + ")");
|
||||
SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM messages " +
|
||||
"WHERE sourceID = " + this.id);
|
||||
// FIXME: don't delete people unless the only identities with which
|
||||
// they are associated are identities associated with this source.
|
||||
SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM people " +
|
||||
"WHERE id IN " +
|
||||
"(SELECT personID FROM identities WHERE sourceID = " + this.id + ")");
|
||||
SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM identities " +
|
||||
"WHERE sourceID = " + this.id);
|
||||
SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM sources " +
|
||||
"WHERE id = " + this.id);
|
||||
|
||||
// Finally, clean up Places bookmarks with sourceID in its prefixed uri.
|
||||
SnowlPlaces.removePlacesItemsByURI("snowl:sourceId=" + this.id, true);
|
||||
|
||||
SnowlDatastore.dbConnection.commitTransaction();
|
||||
}
|
||||
catch(ex) {
|
||||
SnowlDatastore.dbConnection.rollbackTransaction();
|
||||
throw ex;
|
||||
}
|
||||
|
||||
Observers.notify("snowl:source:unstored", this.id);
|
||||
this.id = null;
|
||||
Observers.notify("snowl:source:removed");
|
||||
},
|
||||
|
||||
/**
|
||||
* Update the current flag for messages in a source, after a refresh.
|
||||
* If message's current flag = 1 set to 0, then set current flag for messages
|
||||
|
|
Загрузка…
Ссылка в новой задаче