History

Sanity-check decaffeinate app.views.Sidebar

Simon Legner committed 2 years ago

Commit 978d4a91 parent 49dbba31 file · +12 −41Browse files

Unified · Split

assets/javascripts/views/sidebar/sidebar.js+12−41
@@ -1,30 +1,18 @@
1// TODO: This file was created by bulk-decaffeinate.
2// Sanity-check the conversion and remove this comment.
3/*
4 * decaffeinate suggestions:
5 * DS102: Remove unnecessary code created because of implicit returns
6 * DS103: Rewrite code to no longer use __guard__, or convert again using --optional-chaining
7 * DS206: Consider reworking classes to avoid initClass
8 * DS207: Consider shorter variations of null checks
9 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
10 */
11app.views.Sidebar = class Sidebar extends app.View {1app.views.Sidebar = class Sidebar extends app.View {
12 static initClass() {2 static el = "._sidebar";
13 this.el = "._sidebar";
14 3
15 this.events = {4 static events = {
16 focus: "onFocus",5 focus: "onFocus",
17 select: "onSelect",6 select: "onSelect",
18 click: "onClick",7 click: "onClick",
19 };8 };
20 9
21 this.routes = { after: "afterRoute" };10 static routes = { after: "afterRoute" };
22 11
23 this.shortcuts = {12 static shortcuts = {
24 altR: "onAltR",13 altR: "onAltR",
25 escape: "onEscape",14 escape: "onEscape",
26 };15 };
27 }
28 16
29 init() {17 init() {
30 if (!app.isMobile()) {18 if (!app.isMobile()) {
@@ -179,11 +167,7 @@ app.views.Sidebar = class Sidebar extends app.View { · 148 unmodified lines
179 if (event.which !== 1) {167 if (event.which !== 1) {
180 return;168 return;
181 }169 }
182 if (170 if ($.eventTarget(event).hasAttribute?.("data-reset-list")) {
183 __guardMethod__($.eventTarget(event), "hasAttribute", (o) =>
184 o.hasAttribute("data-reset-list"),
185 )
186 ) {
187 $.stopEvent(event);171 $.stopEvent(event);
188 this.onAltR();172 this.onAltR();
189 }173 }
@@ -225,16 +209,3 @@ app.views.Sidebar = class Sidebar extends app.View { · 35 unmodified lines
225 this.resetDisplay();209 this.resetDisplay();
226 }210 }
227};211};
228app.views.Sidebar.initClass();
229
230function __guardMethod__(obj, methodName, transform) {
231 if (
232 typeof obj !== "undefined" &&
233 obj !== null &&
234 typeof obj[methodName] === "function"
235 ) {
236 return transform(obj, methodName);
237 } else {
238 return undefined;
239 }
240}