Simon Legner 1 year ago
parent eea754d19a
commit f364659d97

@ -66,8 +66,7 @@ app.Router = class Router extends Events {
type(context, next) { type(context, next) {
const doc = app.docs.findBySlug(context.params.doc); const doc = app.docs.findBySlug(context.params.doc);
const type = const type = doc?.types?.findBy("slug", context.params.type);
doc != null ? doc.types.findBy("slug", context.params.type) : undefined;
if (type) { if (type) {
context.doc = doc; context.doc = doc;

@ -312,10 +312,7 @@ app.Searcher = class Searcher extends Events {
} }
scoredEnough() { scoredEnough() {
return ( return this.scoreMap[100]?.length >= this.options.max_results;
(this.scoreMap[100] != null ? this.scoreMap[100].length : undefined) >=
this.options.max_results
);
} }
foundEnough() { foundEnough() {
@ -388,7 +385,7 @@ app.SynchronousSearcher = class SynchronousSearcher extends app.Searcher {
} }
sendResults(end) { sendResults(end) {
if (end && (this.allResults != null ? this.allResults.length : undefined)) { if (end && this.allResults?.length) {
return this.triggerResults(this.allResults); return this.triggerResults(this.allResults);
} }
} }

@ -198,10 +198,7 @@ app.Settings = class Settings {
toggleLayout(layout, enable) { toggleLayout(layout, enable) {
const { classList } = document.body; const { classList } = document.body;
// sidebar is always shown for settings; its state is updated in app.views.Settings // sidebar is always shown for settings; its state is updated in app.views.Settings
if ( if (layout !== "_sidebar-hidden" || !app.router?.isSettings) {
layout !== "_sidebar-hidden" ||
!(app.router != null ? app.router.isSettings : undefined)
) {
classList.toggle(layout, enable); classList.toggle(layout, enable);
} }
classList.toggle("_overlay-scrollbars", $.overlayScrollbarsEnabled()); classList.toggle("_overlay-scrollbars", $.overlayScrollbarsEnabled());

@ -43,7 +43,7 @@ page.stop = function () {
page.show = function (path, state) { page.show = function (path, state) {
let res; let res;
if (path === (currentState != null ? currentState.path : undefined)) { if (path === currentState?.path) {
return; return;
} }
const context = new Context(path, state); const context = new Context(path, state);

@ -453,8 +453,7 @@ $.arrayDelete = function (array, object) {
// Returns true if the object is an array or a collection of DOM elements. // Returns true if the object is an array or a collection of DOM elements.
$.isCollection = (object) => $.isCollection = (object) =>
Array.isArray(object) || Array.isArray(object) || typeof object?.item === "function";
typeof (object != null ? object.item : undefined) === "function";
const ESCAPE_HTML_MAP = { const ESCAPE_HTML_MAP = {
"&": "&", "&": "&",

@ -144,9 +144,7 @@ app.views.EntryPage = class EntryPage extends app.View {
} }
onRoute(context) { onRoute(context) {
const isSameFile = const isSameFile = context.entry.filePath() === this.entry?.filePath?.();
context.entry.filePath() ===
(this.entry != null ? this.entry.filePath() : undefined);
this.entry = context.entry; this.entry = context.entry;
if (!isSameFile) { if (!isSameFile) {
this.restore() || this.load(); this.restore() || this.load();

@ -35,7 +35,7 @@ app.views.SearchScope = class SearchScope extends app.View {
} }
name() { name() {
return this.doc != null ? this.doc.name : undefined; return this.doc?.name;
} }
search(value, searchDisabled) { search(value, searchDisabled) {

@ -83,7 +83,7 @@ app.views.DocList = class DocList extends app.View {
var versions = ""; var versions = "";
while (true) { while (true) {
versions += this.tmpl("sidebarDoc", doc, { disabled: true }); versions += this.tmpl("sidebarDoc", doc, { disabled: true });
if ((docs[0] != null ? docs[0].name : undefined) !== doc.name) { if (docs[0]?.name !== doc.name) {
break; break;
} }
doc = docs.shift(); doc = docs.shift();
@ -144,7 +144,7 @@ app.views.DocList = class DocList extends app.View {
} }
select(model) { select(model) {
this.listSelect.selectByHref(model != null ? model.fullPath() : undefined); this.listSelect.selectByHref(model?.fullPath());
} }
reveal(model) { reveal(model) {

@ -79,7 +79,7 @@ app.views.DocPicker = class DocPicker extends app.View {
getSelectedDocs() { getSelectedDocs() {
return this.findAllByTag("input") return this.findAllByTag("input")
.filter((input) => (input != null ? input.checked : undefined)) .filter((input) => input?.checked)
.map((input) => input.name); .map((input) => input.name);
} }

Loading…
Cancel
Save