mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1022238 - Part 2: Handle removal correctly. r=margaret
This commit is contained in:
parent
330aca79c6
commit
c53883bfee
@ -422,9 +422,6 @@ abstract public class BrowserApp extends GeckoApp
|
||||
public void run() {
|
||||
BrowserDB.removeReadingListItemWithURL(getContentResolver(), url);
|
||||
showToast(R.string.page_removed, Toast.LENGTH_SHORT);
|
||||
|
||||
final int count = BrowserDB.getReadingListCount(getContentResolver());
|
||||
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Reader:ListCountUpdated", Integer.toString(count)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
package org.mozilla.gecko.home;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.mozilla.gecko.EditBookmarkDialog;
|
||||
import org.mozilla.gecko.GeckoApp;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
@ -340,7 +342,16 @@ abstract class HomeFragment extends Fragment {
|
||||
BrowserDB.removeHistoryEntry(cr, mUrl);
|
||||
|
||||
BrowserDB.removeReadingListItemWithURL(cr, mUrl);
|
||||
GeckoEvent e = GeckoEvent.createBroadcastEvent("Reader:Remove", mUrl);
|
||||
|
||||
final JSONObject json = new JSONObject();
|
||||
try {
|
||||
json.put("url", mUrl);
|
||||
json.put("notify", false);
|
||||
} catch (JSONException e) {
|
||||
Log.e(LOGTAG, "error building JSON arguments");
|
||||
}
|
||||
|
||||
GeckoEvent e = GeckoEvent.createBroadcastEvent("Reader:Remove", json.toString());
|
||||
GeckoAppShell.sendEventToGecko(e);
|
||||
|
||||
return null;
|
||||
|
@ -196,9 +196,9 @@ AboutReader.prototype = {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "Reader:Remove": {
|
||||
if (aData == this._article.url) {
|
||||
let args = JSON.parse(aData);
|
||||
if (args.url == this._article.url) {
|
||||
if (this._isReadingListItem != 0) {
|
||||
this._isReadingListItem = 0;
|
||||
this._updateToggleButton();
|
||||
@ -316,7 +316,8 @@ AboutReader.prototype = {
|
||||
// In addition to removing the article from the cache (handled in
|
||||
// browser.js), sending this message will cause the toggle button to be
|
||||
// updated (handled in this file).
|
||||
Services.obs.notifyObservers(null, "Reader:Remove", this._article.url);
|
||||
let json = JSON.stringify({ url: this._article.url, notify: true });
|
||||
Services.obs.notifyObservers(null, "Reader:Remove", json);
|
||||
|
||||
UITelemetry.addEvent("unsave.1", "button", null, "reader");
|
||||
}
|
||||
|
@ -7320,14 +7320,18 @@ let Reader = {
|
||||
}
|
||||
|
||||
case "Reader:Remove": {
|
||||
let url = aData;
|
||||
this.removeArticleFromCache(url, function(success) {
|
||||
this.log("Reader:Remove success=" + success + ", url=" + url);
|
||||
let args = JSON.parse(aData);
|
||||
|
||||
if (success) {
|
||||
if (!("url" in args)) {
|
||||
throw new Error("Reader:Remove requires URL as an argument");
|
||||
}
|
||||
|
||||
this.removeArticleFromCache(args.url, function(success) {
|
||||
this.log("Reader:Remove success=" + success + ", url=" + args.url);
|
||||
if (success && args.notify) {
|
||||
sendMessageToJava({
|
||||
type: "Reader:Removed",
|
||||
url: url
|
||||
url: args.url
|
||||
});
|
||||
}
|
||||
}.bind(this));
|
||||
|
Loading…
Reference in New Issue
Block a user