Skip to content

Commit

Permalink
fix: 🐛 Safety checks for new notes and no markdownView
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Dec 16, 2021
1 parent 389b558 commit 452a54b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
10 changes: 7 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22461,7 +22461,10 @@ const fallbackOppField = (field, dir) => `${field} <${ARROW_DIRECTIONS[getOppDir
function getRealnImplied(plugin, currNode, dir = null) {
const realsnImplieds = blankRealNImplied();
const { userHiers } = plugin.settings;
plugin.mainG.forEachEdge(currNode, (k, a, s, t) => {
const { mainG } = plugin;
if (!mainG.hasNode(currNode))
return realsnImplieds;
mainG.forEachEdge(currNode, (k, a, s, t) => {
var _a;
const { field, dir: edgeDir } = a;
const oppField = (_a = getOppFields(userHiers, field)[0]) !== null && _a !== void 0 ? _a : fallbackOppField(field, edgeDir);
Expand Down Expand Up @@ -24882,6 +24885,8 @@ class MatrixView extends require$$0.ItemView {
const { settings } = this.plugin;
const { userHiers } = settings;
const currFile = this.app.workspace.getActiveFile();
if (!currFile)
return;
contentEl.createEl("button", {
text: this.matrixQ ? "List" : "Matrix",
attr: { "aria-label": "Mode" },
Expand Down Expand Up @@ -52684,8 +52689,7 @@ class BCPlugin extends require$$0.Plugin {
onunload() {
console.log("unloading");
this.VIEWS.forEach(async (view) => {
var _a;
await ((_a = this.getActiveTYPEView(view.type)) === null || _a === void 0 ? void 0 : _a.close());
// await this.getActiveTYPEView(view.type)?.close();
this.app.workspace.detachLeavesOfType(view.type);
});
this.visited.forEach((visit) => visit[1].remove());
Expand Down
11 changes: 4 additions & 7 deletions src/MatrixView.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { debug, error, info } from "loglevel";
import { ItemView, Notice, TFile, WorkspaceLeaf } from "obsidian";
import { error, info } from "loglevel";
import { ItemView, TFile, WorkspaceLeaf } from "obsidian";
import { Debugger } from "src/Debugger";
import Lists from "./Components/Lists.svelte";
import Matrix from "./Components/Matrix.svelte";
Expand All @@ -18,11 +18,7 @@ import type {
UserHier,
} from "./interfaces";
import type BCPlugin from "./main";
import {
fallbackOppField,
getRealnImplied,
linkClass,
} from "./sharedFunctions";
import { getRealnImplied, linkClass } from "./sharedFunctions";

export default class MatrixView extends ItemView {
private plugin: BCPlugin;
Expand Down Expand Up @@ -274,6 +270,7 @@ export default class MatrixView extends ItemView {

const { userHiers } = settings;
const currFile = this.app.workspace.getActiveFile();
if (!currFile) return;

contentEl.createEl(
"button",
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,7 @@ export default class BCPlugin extends Plugin {
onunload(): void {
console.log("unloading");
this.VIEWS.forEach(async (view) => {
await this.getActiveTYPEView(view.type)?.close();
// await this.getActiveTYPEView(view.type)?.close();
this.app.workspace.detachLeavesOfType(view.type);
});

Expand Down
6 changes: 4 additions & 2 deletions src/sharedFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const dropDendron = (path: string, settings: BCSettings) =>

export const dropPathNDendron = (path: string, settings: BCSettings) =>
dropDendron(dropPath(path), settings);

/**
* Get basename from a **Markdown** `path`
* @param {string} path
Expand Down Expand Up @@ -259,8 +259,10 @@ export function getRealnImplied(
): RealNImplied {
const realsnImplieds: RealNImplied = blankRealNImplied();
const { userHiers } = plugin.settings;
const { mainG } = plugin;

plugin.mainG.forEachEdge(currNode, (k, a, s, t) => {
if (!mainG.hasNode(currNode)) return realsnImplieds;
mainG.forEachEdge(currNode, (k, a, s, t) => {
const { field, dir: edgeDir } = a as { field: string; dir: Directions };
const oppField =
getOppFields(userHiers, field)[0] ?? fallbackOppField(field, edgeDir);
Expand Down

0 comments on commit 452a54b

Please sign in to comment.