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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save