Use const, use arrow callbacks

pull/1441/head
Simon Legner 1 year ago
parent 82fd7e6547
commit 9f87a459eb

@ -265,7 +265,7 @@ app.DB = class DB {
}
version(doc, fn) {
let version = this.cachedVersion(doc);
const version = this.cachedVersion(doc);
if (version != null) {
fn(version);
return;
@ -302,7 +302,7 @@ app.DB = class DB {
}
versions(docs, fn) {
let versions = this.cachedVersions(docs);
const versions = this.cachedVersions(docs);
if (versions) {
fn(versions);
return;
@ -324,7 +324,7 @@ app.DB = class DB {
const store = txn.objectStore("docs");
var result = {};
docs.forEach(function (doc) {
docs.forEach((doc) => {
const req = store.get(doc.slug);
req.onsuccess = function () {
result[doc.slug] = req.result;

@ -21,7 +21,7 @@ app.ServiceWorker = class ServiceWorker extends Events {
return;
}
this.notifyUpdate = true;
return this.registration.update().catch(function () {});
return this.registration.update().catch(() => {});
}
updateInBackground() {
@ -29,7 +29,7 @@ app.ServiceWorker = class ServiceWorker extends Events {
return;
}
this.notifyUpdate = false;
return this.registration.update().catch(function () {});
return this.registration.update().catch(() => {});
}
reload() {

@ -13,7 +13,7 @@ app.collections.Docs = class Docs extends app.Collection {
);
}
sort() {
return this.models.sort(function (a, b) {
return this.models.sort((a, b) => {
if (a.name === b.name) {
if (
!a.version ||
@ -81,7 +81,7 @@ app.collections.Docs = class Docs extends app.Collection {
}
getInstallStatuses(callback) {
app.db.versions(this.models, function (statuses) {
app.db.versions(this.models, (statuses) => {
if (statuses) {
for (var key in statuses) {
var value = statuses[key];

@ -34,7 +34,7 @@ class Events {
this.eventInProgress = { name: event, args };
const callbacks = this._callbacks?.[event];
if (callbacks) {
for (let callback of callbacks.slice(0)) {
for (const callback of callbacks.slice(0)) {
if (typeof callback === "function") {
callback(...args);
}

@ -215,7 +215,7 @@ var pathToRegexp = function (path, keys) {
.replace(/\/\(/g, "(?:/")
.replace(
/(\/)?(\.)?:(\w+)(?:(\(.*?\)))?(\?)?/g,
function (_, slash, format, key, capture, optional) {
(_, slash, format, key, capture, optional) => {
if (slash == null) {
slash = "";
}

@ -58,7 +58,7 @@ app.views.Document = class Document extends app.View {
if (this.el.visibilityState !== "visible") {
return;
}
this.delay(function () {
this.delay(() => {
if (app.isMobile() !== app.views.Mobile.detect()) {
location.reload();
}

@ -72,7 +72,7 @@ app.views.Settings = class Settings extends app.View {
return result;
})(),
);
disabledDocs.uninstall(function () {
disabledDocs.uninstall(() => {
app.db.migrate();
return app.reload();
});

@ -18,7 +18,7 @@ app.views.News = class News extends app.views.Notif {
}
getUnreadNews() {
let time = this.getLastReadTime();
const time = this.getLastReadTime();
if (!time) {
return [];
}

@ -207,7 +207,7 @@ app.views.Search = class Search extends app.View {
}
extractHashValue() {
let value = this.getHashValue();
const value = this.getHashValue();
if (value != null) {
app.router.replaceHash();
return value;

Loading…
Cancel
Save