summaryrefslogtreecommitdiff
path: root/js/CommonDialogs.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-03-06 11:17:15 +0300
committerAndrew Dolgov <[email protected]>2021-03-06 11:17:15 +0300
commite5469479c1ee6ddb671659dbb6362eac50f02979 (patch)
tree42fac045821e3111fc07c8dd21f287a546edcd29 /js/CommonDialogs.js
parent42e057c8088070f9afd417d92cf6a0ebc9fdd01f (diff)
* don't try to update custom set feed favicons
* cleanup update_rss_feed() a bit, use ORM
Diffstat (limited to 'js/CommonDialogs.js')
-rw-r--r--js/CommonDialogs.js34
1 files changed, 19 insertions, 15 deletions
diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js
index ea26ee515..b9b053a5a 100644
--- a/js/CommonDialogs.js
+++ b/js/CommonDialogs.js
@@ -3,7 +3,7 @@
/* eslint-disable new-cap */
/* eslint-disable no-new */
-/* global __, dojo, dijit, Notify, App, Feeds, xhrPost, xhr, Tables, fox */
+/* global __, dojo, dijit, Notify, App, Feeds, xhr, Tables, fox */
/* exported CommonDialogs */
const CommonDialogs = {
@@ -181,7 +181,7 @@ const CommonDialogs = {
}
} catch (e) {
- console.error(transport.responseText);
+ console.error(reply);
App.Error.report(e);
}
});
@@ -335,6 +335,10 @@ const CommonDialogs = {
id: "feedEditDlg",
title: __("Edit feed"),
feed_title: "",
+ E_ICON_FILE_TOO_LARGE: 'E_ICON_FILE_TOO_LARGE',
+ E_ICON_RENAME_FAILED: 'E_ICON_RENAME_FAILED',
+ E_ICON_UPLOAD_FAILED: 'E_ICON_UPLOAD_FAILED',
+ E_ICON_UPLOAD_SUCCESS: 'E_ICON_UPLOAD_SUCCESS',
unsubscribe: function() {
if (confirm(__("Unsubscribe from %s?").replace("%s", this.feed_title))) {
dialog.hide();
@@ -361,20 +365,18 @@ const CommonDialogs = {
xhr.open( 'POST', 'backend.php', true );
xhr.onload = function () {
- console.log(this.responseText);
+ const ret = JSON.parse(this.responseText);
// TODO: make a notice box within panel content
- switch (parseInt(this.responseText)) {
- case 1:
- Notify.error("Upload failed: icon is too big.");
+ switch (ret.rc) {
+ case dialog.E_ICON_FILE_TOO_LARGE:
+ alert(__("Icon file is too large."));
break;
- case 2:
- Notify.error("Upload failed.");
+ case dialog.E_ICON_UPLOAD_FAILED:
+ alert(__("Upload failed."));
break;
- default:
+ case dialog.E_ICON_UPLOAD_SUCCESS:
{
- Notify.info("Upload complete.");
-
if (App.isPrefs())
dijit.byId("feedTree").reload();
else
@@ -383,12 +385,16 @@ const CommonDialogs = {
const icon = dialog.domNode.querySelector(".feedIcon");
if (icon) {
- icon.src = this.responseText;
+ icon.src = ret.icon_url;
icon.show();
}
input.value = "";
}
+ break;
+ default:
+ alert(this.responseText);
+ break;
}
};
@@ -400,9 +406,7 @@ const CommonDialogs = {
if (confirm(__("Remove stored feed icon?"))) {
Notify.progress("Removing feed icon...", true);
- const query = {op: "pref-feeds", method: "removeicon", feed_id: id};
-
- xhr.post("backend.php", query, () => {
+ xhr.post("backend.php", {op: "pref-feeds", method: "removeicon", feed_id: id}, () => {
Notify.info("Feed icon removed.");
if (App.isPrefs())