|
|
@@ -2,7 +2,7 @@ import { i18n, request } from 'src/common';
|
|
|
import { parseScript } from './db';
|
|
|
import { parseMeta, compareVersion } from './script';
|
|
|
import { getOption } from './options';
|
|
|
-import { notify } from '.';
|
|
|
+import { notify, sendMessageOrIgnore } from '.';
|
|
|
|
|
|
const processes = {};
|
|
|
|
|
|
@@ -30,34 +30,34 @@ function doCheckUpdate(script) {
|
|
|
if (compareVersion(script.meta.version, meta.version) < 0) return Promise.resolve();
|
|
|
update.checking = false;
|
|
|
update.message = i18n('msgNoUpdate');
|
|
|
- browser.runtime.sendMessage(res);
|
|
|
+ sendMessageOrIgnore(res);
|
|
|
return Promise.reject();
|
|
|
};
|
|
|
const errHandler = () => {
|
|
|
update.checking = false;
|
|
|
update.message = i18n('msgErrorFetchingUpdateInfo');
|
|
|
- browser.runtime.sendMessage(res);
|
|
|
+ sendMessageOrIgnore(res);
|
|
|
return Promise.reject();
|
|
|
};
|
|
|
const doUpdate = () => {
|
|
|
if (!downloadURL) {
|
|
|
update.message = `<span class="new">${i18n('msgNewVersion')}</span>`;
|
|
|
- browser.runtime.sendMessage(res);
|
|
|
+ sendMessageOrIgnore(res);
|
|
|
return Promise.reject();
|
|
|
}
|
|
|
update.message = i18n('msgUpdating');
|
|
|
- browser.runtime.sendMessage(res);
|
|
|
+ sendMessageOrIgnore(res);
|
|
|
return request(downloadURL)
|
|
|
.then(({ data }) => data, () => {
|
|
|
update.checking = false;
|
|
|
update.message = i18n('msgErrorFetchingScript');
|
|
|
- browser.runtime.sendMessage(res);
|
|
|
+ sendMessageOrIgnore(res);
|
|
|
return Promise.reject();
|
|
|
});
|
|
|
};
|
|
|
if (!updateURL) return Promise.reject();
|
|
|
update.message = i18n('msgCheckingForUpdate');
|
|
|
- browser.runtime.sendMessage(res);
|
|
|
+ sendMessageOrIgnore(res);
|
|
|
return request(updateURL, {
|
|
|
headers: {
|
|
|
Accept: 'text/x-userscript-meta',
|
|
|
@@ -80,7 +80,7 @@ export default function checkUpdate(script) {
|
|
|
.then(res => {
|
|
|
const { data: { update } } = res;
|
|
|
update.checking = false;
|
|
|
- browser.runtime.sendMessage(res);
|
|
|
+ sendMessageOrIgnore(res);
|
|
|
updated = true;
|
|
|
if (getOption('notifyUpdates')) {
|
|
|
notify({
|