Sanity-check decaffeinate app.views.TypeList

pull/1441/head
Simon Legner 1 year ago
parent 6df17da955
commit a1713ed4ac

@ -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
* DS103: Rewrite code to no longer use __guard__, or convert again using --optional-chaining
* DS206: Consider reworking classes to avoid initClass
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/
app.views.TypeList = class TypeList extends app.View { app.views.TypeList = class TypeList extends app.View {
static initClass() { static tagName = "div";
this.tagName = "div"; static className = "_list _list-sub";
this.className = "_list _list-sub";
this.events = { static events = {
open: "onOpen", open: "onOpen",
close: "onClose", close: "onClose",
}; };
}
constructor(doc) { constructor(doc) {
super(); super();
@ -52,7 +40,7 @@ app.views.TypeList = class TypeList extends app.View {
render() { render() {
let html = ""; let html = "";
for (var group of Array.from(this.doc.types.groups())) { for (var group of this.doc.types.groups()) {
html += this.tmpl("sidebarType", group); html += this.tmpl("sidebarType", group);
} }
return this.html(html); return this.html(html);
@ -86,14 +74,7 @@ app.views.TypeList = class TypeList extends app.View {
paginateTo(model) { paginateTo(model) {
if (model.type) { if (model.type) {
__guard__(this.lists[model.getType().slug], (x) => x.paginateTo(model)); this.lists[model.getType().slug]?.paginateTo(model);
} }
} }
}; };
app.views.TypeList.initClass();
function __guard__(value, transform) {
return typeof value !== "undefined" && value !== null
? transform(value)
: undefined;
}

Loading…
Cancel
Save