History

Sanity-check decaffeinate app.views.TypeList

Simon Legner committed 2 years ago

Commit a1713ed1 parent 6df17da1 file · +8 −27Browse files

Unified · Split

assets/javascripts/views/sidebar/type_list.js+8−27
@@ -1,23 +1,11 @@
1−// TODO: This file was created by bulk-decaffeinate.
2−// Sanity-check the conversion and remove this comment.
3−/*
4− * decaffeinate suggestions:
5− * DS101: Remove unnecessary use of Array.from
6− * DS102: Remove unnecessary code created because of implicit returns
7− * DS103: Rewrite code to no longer use __guard__, or convert again using --optional-chaining
8− * DS206: Consider reworking classes to avoid initClass
9− * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
10− */
111 app.views.TypeList = class TypeList extends app.View {
12− static initClass() {
13− this.tagName = "div";
14− this.className = "_list _list-sub";
2+ static tagName = "div";
3+ static className = "_list _list-sub";
154
16− this.events = {
17− open: "onOpen",
18− close: "onClose",
19− };
20− }
5+ static events = {
6+ open: "onOpen",
7+ close: "onClose",
8+ };
219
2210 constructor(doc) {
2311 super();
@@ -52,7 +40,7 @@ app.views.TypeList = class TypeList extends app.View { · 28 unmodified lines
5240
5341 render() {
5442 let html = "";
55− for (var group of Array.from(this.doc.types.groups())) {
43+ for (var group of this.doc.types.groups()) {
5644 html += this.tmpl("sidebarType", group);
5745 }
5846 return this.html(html);
@@ -86,14 +74,7 @@ app.views.TypeList = class TypeList extends app.View { · 27 unmodified lines
8674
8775 paginateTo(model) {
8876 if (model.type) {
89− __guard__(this.lists[model.getType().slug], (x) => x.paginateTo(model));
77+ this.lists[model.getType().slug]?.paginateTo(model);
9078 }
9179 }
9280 };
93−app.views.TypeList.initClass();
94−
95−function __guard__(value, transform) {
96− return typeof value !== "undefined" && value !== null
97− ? transform(value)
98− : undefined;
99−}