зеркало из https://github.com/mozilla/snowl.git
(no commit message)
This commit is contained in:
Родитель
4654426b3c
Коммит
031a4fd488
|
@ -573,7 +573,8 @@ this._log.info("onClick: START itemIds - " +this.itemIds.toSource());
|
|||
if (authors.length > 0) {
|
||||
if (sources.length > 0)
|
||||
query += " OR ";
|
||||
query += "authorID = " + authors.join(" OR authorID = ");
|
||||
query += "authorID IN (SELECT id FROM identities " +
|
||||
" WHERE personID IN ( " + authors + " ))";
|
||||
}
|
||||
|
||||
query = query ? "( " + query + " ) AND " : null;
|
||||
|
@ -593,7 +594,6 @@ this._log.info("onClick: START itemIds - " +this.itemIds.toSource());
|
|||
},
|
||||
|
||||
markCollectionNewState: function() {
|
||||
//this._log.info("markCollectionNewState: START ");
|
||||
// Mark all selected source/author collection messages as not new (unread)
|
||||
// upon the collection being no longer selected. Note: shift-click on a
|
||||
// collection will leave new state when unselected.
|
||||
|
@ -631,7 +631,8 @@ this._log.info("onClick: START itemIds - " +this.itemIds.toSource());
|
|||
if (authors.length > 0) {
|
||||
if (sources.length > 0)
|
||||
query += " OR ";
|
||||
query += "authorID = " + authors.join(" OR authorID = ");
|
||||
query += "authorID IN (SELECT id FROM identities " +
|
||||
" WHERE personID IN ( " + authors + " ))";
|
||||
}
|
||||
|
||||
query = query ? "( " + query + " ) AND " : null;
|
||||
|
@ -665,7 +666,8 @@ this._log.info("onClick: START itemIds - " +this.itemIds.toSource());
|
|||
for (let i = 0; i < selectedSourceIDs.length; ++i) {
|
||||
sourceID = selectedSourceIDs[i];
|
||||
source = SnowlService.sourcesByID[sourceID];
|
||||
this._log.info("removeSource: Removing source - " + source.id + " : " + source.name);
|
||||
this._log.info("removeSource: Removing source - " +
|
||||
source.id + " : " + source.name);
|
||||
source.unstore();
|
||||
}
|
||||
},
|
||||
|
@ -686,10 +688,11 @@ this._log.info("removeSource: Removing source - " + source.id + " : " + source.n
|
|||
// Create places query object from tree item uri
|
||||
let query = new SnowlQuery(selectedSource.uri);
|
||||
|
||||
if (query.queryGroupIDColumn != "people.id")
|
||||
if (!query.queryTypeAuthor)
|
||||
return;
|
||||
this._log.info("removeAuthor: Removing author - " + selectedSource.title + " : " + selectedSource.itemId);
|
||||
|
||||
this._log.info("removeAuthor: Removing author - " +
|
||||
selectedSource.title + " : " + selectedSource.itemId);
|
||||
selectedSourceNodeID = [selectedSource, query.queryID];
|
||||
selectedSourceNodesIDs.push(selectedSourceNodeID);
|
||||
|
||||
|
@ -885,10 +888,10 @@ this._log.info("removeAuthor: Removing author - " + selectedSource.title + " : "
|
|||
for (let index = rangeFirst.value; index <= rangeLast.value; index++) {
|
||||
uri = this._tree.view.nodeForTreeIndex(index).uri;
|
||||
query = new SnowlQuery(uri);
|
||||
if ((query.queryGroupIDColumn == "sources.id" &&
|
||||
query.queryID == aMessage.source.id) ||
|
||||
(query.queryGroupIDColumn == "people.id" &&
|
||||
query.queryID == aMessage.author.id) ||
|
||||
if ((query.queryTypeSource && query.queryID == aMessage.source.id) ||
|
||||
(query.queryTypeAuthor && query.queryID == (aMessage.author ?
|
||||
aMessage.author.person.id :
|
||||
null)) ||
|
||||
// Collection folders that return all records
|
||||
query.queryFolder == SnowlPlaces.collectionsSystemID)
|
||||
refreshFlag = true;
|
||||
|
|
|
@ -156,6 +156,7 @@
|
|||
itemids="-1"
|
||||
hidecolumnpicker="true"
|
||||
context="placesContext"
|
||||
_selectDelay="500"
|
||||
onkeypress="SidebarUtils.handleTreeKeyPress(event);"
|
||||
onmousemove="SidebarUtils.handleTreeMouseMove(event);"
|
||||
onmouseout="SidebarUtils.clearURLFromStatusBar();"
|
||||
|
|
|
@ -416,7 +416,9 @@ let SnowlMessageView = {
|
|||
// On conversion of list tree to places, this will be stored in
|
||||
// currentSelectedIndex as for collections tree..
|
||||
// SnowlUtils.gListViewListIndex = row;
|
||||
this._setRead(true);
|
||||
|
||||
if (message.read == MESSAGE_UNREAD)
|
||||
this._setRead(true);
|
||||
// If new message selected, reset for toggle
|
||||
SnowlUtils.gMessagePosition.pageIndex = null;
|
||||
},
|
||||
|
@ -772,6 +774,9 @@ let SnowlMessageView = {
|
|||
if (markDeletedMessageIDs.length > 0)
|
||||
SnowlMessage.markDeletedState(markDeletedMessageIDs, true);
|
||||
|
||||
// Reset stats.
|
||||
SnowlService._collectionStatsByCollectionID = null;
|
||||
this.CollectionsView._tree.treeBoxObject.invalidate();
|
||||
//this._log.info("_deleteMessages: END");
|
||||
//this._log.info(" ");
|
||||
},
|
||||
|
@ -875,6 +880,10 @@ let SnowlMessageView = {
|
|||
}
|
||||
|
||||
SnowlMessage.markDeletedState(messageIDs, false);
|
||||
|
||||
// Reset stats.
|
||||
SnowlService._collectionStatsByCollectionID = null;
|
||||
this.CollectionsView._tree.treeBoxObject.invalidate();
|
||||
},
|
||||
|
||||
onListTreeMouseDown: function(aEvent) {
|
||||
|
|
|
@ -770,30 +770,53 @@ let SnowlDatastore = {
|
|||
return [name, username];
|
||||
},
|
||||
|
||||
get _selectHasAuthorMessageStatement() {
|
||||
get _selectHasIdentityMessageStatement() {
|
||||
let statement = this.createStatement(
|
||||
"SELECT 1 FROM messages" +
|
||||
" WHERE authorID = :authorID AND" +
|
||||
" current <> " + MESSAGE_CURRENT_PENDING_PURGE
|
||||
"SELECT 1 FROM messages " +
|
||||
"WHERE authorID = :authorID AND " +
|
||||
" current <> " + MESSAGE_CURRENT_PENDING_PURGE
|
||||
);
|
||||
this.__defineGetter__("_selectHasAuthorMessageStatement", function() { return statement });
|
||||
return this._selectHasAuthorMessageStatement;
|
||||
this.__defineGetter__("_selectHasIdentityMessageStatement", function() { return statement });
|
||||
return this._selectHasIdentityMessageStatement;
|
||||
},
|
||||
|
||||
selectHasAuthorMessage: function(aAuthorID) {
|
||||
selectHasIdentityMessage: function(aAuthorID) {
|
||||
let hasMessage = false;
|
||||
try {
|
||||
this._selectHasAuthorMessageStatement.params.authorID = aAuthorID;
|
||||
if (this._selectHasAuthorMessageStatement.step())
|
||||
this._selectHasIdentityMessageStatement.params.authorID = aAuthorID;
|
||||
if (this._selectHasIdentityMessageStatement.step())
|
||||
hasMessage = true;
|
||||
}
|
||||
finally {
|
||||
this._selectHasAuthorMessageStatement.reset();
|
||||
this._selectHasIdentityMessageStatement.reset();
|
||||
}
|
||||
|
||||
return hasMessage;
|
||||
},
|
||||
|
||||
get _selectHasAuthorIdentityStatement() {
|
||||
let statement = this.createStatement(
|
||||
"SELECT 1 FROM identities " +
|
||||
"WHERE personID = :authorID"
|
||||
);
|
||||
this.__defineGetter__("_selectHasAuthorIdentityStatement", function() { return statement });
|
||||
return this._selectHasAuthorIdentityStatement;
|
||||
},
|
||||
|
||||
selectHasAuthorIdentity: function(aAuthorID) {
|
||||
let hasIdentity = false;
|
||||
try {
|
||||
this._selectHasAuthorIdentityStatement.params.authorID = aAuthorID;
|
||||
if (this._selectHasAuthorIdentityStatement.step())
|
||||
hasIdentity = true;
|
||||
}
|
||||
finally {
|
||||
this._selectHasAuthorIdentityStatement.reset();
|
||||
}
|
||||
|
||||
return hasIdentity;
|
||||
},
|
||||
|
||||
get _insertMessageStatement() {
|
||||
let statement = this.createStatement(
|
||||
"INSERT INTO messages(sourceID, externalID, subject, authorID, timestamp, received, link) \
|
||||
|
@ -865,27 +888,44 @@ let SnowlDatastore = {
|
|||
},
|
||||
|
||||
_collectionStatsStatement: function(aType) {
|
||||
let typeID = aType == "*" ? "id" :
|
||||
aType == "source" ? "sourceID" :
|
||||
aType == "author" ? "authorID" : null;
|
||||
let groupBy = aType == "*" ? "" :
|
||||
aType == "source" ? "GROUP BY collectionID" :
|
||||
aType == "author" ? "GROUP BY collectionID" : null;
|
||||
let statement = this.createStatement(
|
||||
"SELECT " + typeID + " AS collectionID, " +
|
||||
" COUNT(messages.id) AS total, " +
|
||||
" SUM(read) AS read, " +
|
||||
" SUM(ROUND(read/2,0)) AS new " +
|
||||
"FROM messages " +
|
||||
"WHERE (current = " + MESSAGE_NON_CURRENT + " OR " +
|
||||
" current = " + MESSAGE_CURRENT + ") " + groupBy);
|
||||
let query;
|
||||
switch (aType) {
|
||||
case "all":
|
||||
query = "SELECT id AS collectionID, " +
|
||||
" COUNT(messages.id) AS total, " +
|
||||
" SUM(read) AS read, " +
|
||||
" SUM(ROUND(read/2,0)) AS new " +
|
||||
"FROM messages " +
|
||||
"WHERE (current = " + MESSAGE_NON_CURRENT + " OR " +
|
||||
" current = " + MESSAGE_CURRENT + ") ";
|
||||
break;
|
||||
case "source":
|
||||
query = "SELECT sourceID AS collectionID, " +
|
||||
" COUNT(messages.id) AS total, " +
|
||||
" SUM(read) AS read, " +
|
||||
" SUM(ROUND(read/2,0)) AS new " +
|
||||
"FROM messages " +
|
||||
"WHERE (current = " + MESSAGE_NON_CURRENT + " OR " +
|
||||
" current = " + MESSAGE_CURRENT + ") GROUP BY collectionID";
|
||||
break;
|
||||
case "author":
|
||||
query = "SELECT authorID, identities.id, identities.personID AS collectionID, " +
|
||||
" COUNT(messages.id) AS total, " +
|
||||
" SUM(read) AS read, " +
|
||||
" SUM(ROUND(read/2,0)) AS new " +
|
||||
"FROM messages " +
|
||||
"LEFT JOIN identities ON messages.authorID = identities.id " +
|
||||
"WHERE (current = " + MESSAGE_NON_CURRENT + " OR " +
|
||||
" current = " + MESSAGE_CURRENT + ") GROUP BY collectionID";
|
||||
break;
|
||||
}
|
||||
|
||||
return statement;
|
||||
return this.createStatement(query);
|
||||
},
|
||||
|
||||
collectionStatsByCollectionID: function() {
|
||||
// Stats object for collections tree properties.
|
||||
let statement, type, types = ["*", "source", "author"];
|
||||
let statement, type, types = ["all", "source", "author"];
|
||||
let collectionID, Total, Read, New, collectionStats = {};
|
||||
|
||||
try {
|
||||
|
@ -895,7 +935,7 @@ let SnowlDatastore = {
|
|||
if (statement.row["collectionID"] == null)
|
||||
continue;
|
||||
|
||||
collectionID = type[0] == "*" ?
|
||||
collectionID = type == "all" ?
|
||||
"all" : type[0] + statement.row["collectionID"];
|
||||
|
||||
Total = statement.row["total"];
|
||||
|
|
|
@ -68,8 +68,10 @@ SnowlMessage.retrieve = function(id) {
|
|||
|
||||
// FIXME: memoize this.
|
||||
let statement = SnowlDatastore.createStatement(
|
||||
"SELECT sourceID, externalID, subject, authorID, timestamp, received, link, current, read " +
|
||||
"FROM messages WHERE messages.id = :id"
|
||||
"SELECT sourceID, externalID, subject, authorID, " +
|
||||
" timestamp, received, link, current, read " +
|
||||
"FROM messages " +
|
||||
"WHERE messages.id = :id"
|
||||
);
|
||||
|
||||
try {
|
||||
|
@ -110,40 +112,47 @@ SnowlMessage.delete = function(aMessage) {
|
|||
|
||||
SnowlDatastore.dbConnection.beginTransaction();
|
||||
try {
|
||||
// Delete messages
|
||||
SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM partsText " +
|
||||
"WHERE docid IN " +
|
||||
"(SELECT id FROM parts WHERE messageID = " + messageID + ")");
|
||||
//this._log.info("_deleteMessages: Delete messages PARTSTEXT DONE");
|
||||
SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM parts " +
|
||||
"WHERE messageID = " + messageID);
|
||||
//this._log.info("_deleteMessages: Delete messages PARTS DONE");
|
||||
// If a message is current and marked deleted, need to keep the record so
|
||||
// duplicates are not re added upon refresh. So we move to a pending purge
|
||||
// state and delete the rest of the message.
|
||||
// Delete a message and its parts.
|
||||
SnowlDatastore.dbConnection.executeSimpleSQL(
|
||||
"DELETE FROM partsText " +
|
||||
"WHERE docid IN " +
|
||||
"(SELECT id FROM parts WHERE messageID = " + messageID + ")");
|
||||
SnowlDatastore.dbConnection.executeSimpleSQL(
|
||||
"DELETE FROM parts " +
|
||||
"WHERE messageID = " + messageID);
|
||||
|
||||
if (current == MESSAGE_CURRENT_DELETED)
|
||||
SnowlDatastore.dbConnection.executeSimpleSQL("UPDATE messages " +
|
||||
"SET current = " + MESSAGE_CURRENT_PENDING_PURGE +
|
||||
" WHERE id = " + messageID);
|
||||
// If a message is current and marked deleted, need to keep the record so
|
||||
// duplicates are not re added upon refresh. So we move to a pending purge
|
||||
// state and delete the rest of the message.
|
||||
SnowlDatastore.dbConnection.executeSimpleSQL(
|
||||
"UPDATE messages " +
|
||||
"SET current = " + MESSAGE_CURRENT_PENDING_PURGE +
|
||||
" WHERE id = " + messageID);
|
||||
else
|
||||
SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM messages " +
|
||||
"WHERE id = " + messageID);
|
||||
//this._log.info("_deleteMessages: Delete messages DONE");
|
||||
if (message.author && !SnowlService.hasAuthorMessage(message.author.person.id)) {
|
||||
// Delete people/identities; author's only message has been deleted.
|
||||
SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM people " +
|
||||
"WHERE id = " + message.author.person.id);
|
||||
SnowlDatastore.dbConnection.executeSimpleSQL("DELETE FROM identities " +
|
||||
"WHERE id = " + message.author.id);
|
||||
SnowlDatastore.dbConnection.executeSimpleSQL(
|
||||
"DELETE FROM messages " +
|
||||
"WHERE id = " + messageID);
|
||||
|
||||
// Check if author/identity needs to be deleted.
|
||||
if (message.author && !SnowlService.hasIdentityMessage(message.author.id)) {
|
||||
// Delete identity if its only message has been deleted.
|
||||
SnowlDatastore.dbConnection.executeSimpleSQL(
|
||||
"DELETE FROM identities " +
|
||||
"WHERE id = " + message.author.id);
|
||||
|
||||
if (message.author && !SnowlService.hasAuthorIdentity(message.author.person.id))
|
||||
// Delete author if author's only identity has been deleted.
|
||||
SnowlDatastore.dbConnection.executeSimpleSQL(
|
||||
"DELETE FROM people " +
|
||||
"WHERE id = " + message.author.person.id);
|
||||
|
||||
// Finally, clean up Places bookmark by author's placeID. A collections
|
||||
// tree rebuild is triggered by Places on removeItem of a visible item,
|
||||
// triggering a select event. Need to bypass in onSelect.
|
||||
SnowlMessage.prototype.CollectionsView.noSelect = true;
|
||||
PlacesUtils.bookmarks.removeItem(message.author.person.placeID);
|
||||
//this._log.info("_deleteMessages: Delete DONE authorID - "+authorID);
|
||||
}
|
||||
// PlacesUtils.history.removePage(URI(this.MESSAGE_URI + messageID));
|
||||
//SnowlPlaces._log.info("_deleteMessages: Delete DONE messageID - "+messageID);
|
||||
|
||||
SnowlDatastore.dbConnection.commitTransaction();
|
||||
}
|
||||
|
@ -154,20 +163,18 @@ SnowlMessage.delete = function(aMessage) {
|
|||
};
|
||||
|
||||
SnowlMessage.markDeletedState = function(aMessageIDs, aState) {
|
||||
// If aState is true, mark deleted; if false, mark undeleted.
|
||||
//SnowlPlaces._log.info("markDeletedState: aMessageIDs - "+aMessageIDs);
|
||||
|
||||
// If aState is true, mark deleted; if false, mark undeleted. Make sure caller
|
||||
// checks for delete status first.
|
||||
SnowlDatastore.dbConnection.beginTransaction();
|
||||
try {
|
||||
// Mark message delete state, make sure this caller checks for delete status first.
|
||||
SnowlDatastore.dbConnection.executeSimpleSQL(
|
||||
"UPDATE messages SET current =" +
|
||||
"UPDATE messages SET current = " +
|
||||
" (CASE WHEN current = " + (aState ? MESSAGE_NON_CURRENT : MESSAGE_NON_CURRENT_DELETED) +
|
||||
" THEN " + (aState ? MESSAGE_NON_CURRENT_DELETED : MESSAGE_NON_CURRENT) +
|
||||
" WHEN current = " + (aState ? MESSAGE_CURRENT : MESSAGE_CURRENT_DELETED) +
|
||||
" THEN " + (aState ? MESSAGE_CURRENT_DELETED : MESSAGE_CURRENT) +
|
||||
" END)" +
|
||||
" WHERE id IN ( " + aMessageIDs + " )"
|
||||
" END) " +
|
||||
"WHERE id IN ( " + aMessageIDs + " )"
|
||||
);
|
||||
|
||||
SnowlDatastore.dbConnection.commitTransaction();
|
||||
|
|
|
@ -337,8 +337,19 @@ let SnowlService = {
|
|||
*
|
||||
* @returns {boolean} whether or not the author has a message
|
||||
*/
|
||||
hasAuthorMessage: function(aAuthorID) {
|
||||
return SnowlDatastore.selectHasAuthorMessage(aAuthorID);
|
||||
hasIdentityMessage: function(aAuthorID) {
|
||||
return SnowlDatastore.selectHasIdentityMessage(aAuthorID);
|
||||
},
|
||||
|
||||
/**
|
||||
* Determine whether or not an author has at least one identity in the database.
|
||||
*
|
||||
* @param aAuthorID {string} the identity ID of the message
|
||||
*
|
||||
* @returns {boolean} whether or not the author has an identity
|
||||
*/
|
||||
hasAuthorIdentity: function(aAuthorID) {
|
||||
return SnowlDatastore.selectHasAuthorIdentity(aAuthorID);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче