Sanity-check decaffeinate app.views.Notif

pull/1441/head
Simon Legner 1 year ago
parent 9073fa20cb
commit 1efb79404f

@ -1,23 +1,11 @@
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
* DS102: Remove unnecessary code created because of implicit returns
* DS205: Consider reworking code to avoid use of IIFEs
* DS206: Consider reworking classes to avoid initClass
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/
//= require views/misc/notif //= require views/misc/notif
app.views.News = class News extends app.views.Notif { app.views.News = class News extends app.views.Notif {
static initClass() { static className = "_notif _notif-news";
this.className += " _notif-news";
this.defautOptions = { autoHide: 30000 }; static defaultOptions = { autoHide: 30000 };
}
init() { init0() {
this.unreadNews = this.getUnreadNews(); this.unreadNews = this.getUnreadNews();
if (this.unreadNews.length) { if (this.unreadNews.length) {
this.show(); this.show();
@ -30,21 +18,19 @@ app.views.News = class News extends app.views.Notif {
} }
getUnreadNews() { getUnreadNews() {
let time; let time = this.getLastReadTime();
if (!(time = this.getLastReadTime())) { if (!time) {
return []; return [];
} }
return (() => {
const result = []; const result = [];
for (var news of Array.from(app.news)) { for (var news of app.news) {
if (new Date(news[0]).getTime() <= time) { if (new Date(news[0]).getTime() <= time) {
break; break;
} }
result.push(news); result.push(news);
} }
return result; return result;
})();
} }
getLastNewsTime() { getLastNewsTime() {
@ -59,4 +45,3 @@ app.views.News = class News extends app.views.Notif {
app.settings.set("news", this.getLastNewsTime()); app.settings.set("news", this.getLastNewsTime());
} }
}; };
app.views.News.initClass();

@ -1,15 +1,6 @@
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS206: Consider reworking classes to avoid initClass
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/
app.views.Notice = class Notice extends app.View { app.views.Notice = class Notice extends app.View {
static initClass() { static className = "_notice";
this.className = "_notice"; static attributes = { role: "alert" };
this.attributes = { role: "alert" };
}
constructor(type, ...args) { constructor(type, ...args) {
super(); super();
@ -44,4 +35,3 @@ app.views.Notice = class Notice extends app.View {
$.remove(this.el); $.remove(this.el);
} }
}; };
app.views.Notice.initClass();

@ -1,29 +1,21 @@
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS206: Consider reworking classes to avoid initClass
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/
app.views.Notif = class Notif extends app.View { app.views.Notif = class Notif extends app.View {
static initClass() { static className = "_notif";
this.className = "_notif"; static activeClass = "_in";
this.activeClass = "_in"; static attributes = { role: "alert" };
this.attributes = { role: "alert" };
this.defaultOptions = { autoHide: 15000 }; static defaultOptions = { autoHide: 15000 };
this.events = { click: "onClick" }; static events = { click: "onClick" };
}
constructor(type, options) { constructor(type, options) {
super(); super();
this.type = type; this.type = type;
this.options = $.extend({}, this.constructor.defaultOptions, options || {}); this.options = $.extend({}, this.constructor.defaultOptions, options || {});
this.init0(); // needs this.options
this.refreshElements();
} }
init() { init0() {
this.show(); this.show();
} }
@ -55,7 +47,7 @@ app.views.Notif = class Notif extends app.View {
} }
position() { position() {
const notifications = $$(`.${app.views.Notif.className}`); const notifications = $$(`.${Notif.className}`);
if (notifications.length) { if (notifications.length) {
const lastNotif = notifications[notifications.length - 1]; const lastNotif = notifications[notifications.length - 1];
this.el.style.top = this.el.style.top =
@ -77,4 +69,3 @@ app.views.Notif = class Notif extends app.View {
} }
} }
}; };
app.views.Notif.initClass();

@ -1,21 +1,11 @@
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS206: Consider reworking classes to avoid initClass
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/
//= require views/misc/notif //= require views/misc/notif
app.views.Tip = class Tip extends app.views.Notif { app.views.Tip = class Tip extends app.views.Notif {
static initClass() { static className = "_notif _notif-tip";
this.className = "_notif _notif-tip";
this.defautOptions = { autoHide: false }; static defautOptions = { autoHide: false };
}
render() { render() {
this.html(this.tmpl(`tip${this.type}`)); this.html(this.tmpl(`tip${this.type}`));
} }
}; };
app.views.Tip.initClass();

@ -1,23 +1,11 @@
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
* DS102: Remove unnecessary code created because of implicit returns
* DS205: Consider reworking code to avoid use of IIFEs
* DS206: Consider reworking classes to avoid initClass
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/
//= require views/misc/notif //= require views/misc/notif
app.views.Updates = class Updates extends app.views.Notif { app.views.Updates = class Updates extends app.views.Notif {
static initClass() { static className = "_notif _notif-news";
this.className += " _notif-news";
this.defautOptions = { autoHide: 30000 }; static defautOptions = { autoHide: 30000 };
}
init() { init0() {
this.lastUpdateTime = this.getLastUpdateTime(); this.lastUpdateTime = this.getLastUpdateTime();
this.updatedDocs = this.getUpdatedDocs(); this.updatedDocs = this.getUpdatedDocs();
this.updatedDisabledDocs = this.getUpdatedDisabledDocs(); this.updatedDisabledDocs = this.getUpdatedDisabledDocs();
@ -46,7 +34,6 @@ app.views.Updates = class Updates extends app.views.Notif {
if (!this.lastUpdateTime) { if (!this.lastUpdateTime) {
return []; return [];
} }
return (() => {
const result = []; const result = [];
for (var doc of Array.from(app.disabledDocs.all())) { for (var doc of Array.from(app.disabledDocs.all())) {
if ( if (
@ -57,7 +44,6 @@ app.views.Updates = class Updates extends app.views.Notif {
} }
} }
return result; return result;
})();
} }
getLastUpdateTime() { getLastUpdateTime() {
@ -73,4 +59,3 @@ app.views.Updates = class Updates extends app.views.Notif {
); );
} }
}; };
app.views.Updates.initClass();

Loading…
Cancel
Save