Skip to content

Commit

Permalink
fix(nextPrev): 🐛 Remove duplicate implied
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Nov 18, 2021
1 parent 141b4f9 commit 8fc11e9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
15 changes: 13 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -35437,8 +35437,19 @@ class BCPlugin extends obsidian.Plugin {
debug(settings, { sortedTrails });
const { basename } = currFile;
const { rPrev, rNext, iPrev, iNext } = getPrevNext(this, basename);
const next = [...rNext, ...iNext];
const prev = [...rPrev, ...iPrev];
// Remove duplicate implied
const next = [...rNext];
iNext.forEach((i) => {
if (next.findIndex((n) => n.to === i.to) === -1) {
next.push(i);
}
});
const prev = [...rPrev];
iPrev.forEach((i) => {
if (prev.findIndex((n) => n.to === i.to) === -1) {
prev.push(i);
}
});
const noItems = sortedTrails.length === 0 && next.length === 0 && prev.length === 0;
if (noItems && settings.noPathMessage === "") {
debugGroupEnd(settings, "debugMode");
Expand Down
23 changes: 17 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Notice,
Plugin,
TFile,
WorkspaceLeaf
WorkspaceLeaf,
} from "obsidian";
import { openView, wait } from "obsidian-community-lib/dist/utils";
import { BCSettingTab } from "src/BreadcrumbsSettingTab";
Expand All @@ -17,14 +17,14 @@ import {
MATRIX_VIEW,
STATS_VIEW,
TRAIL_ICON,
TRAIL_ICON_SVG
TRAIL_ICON_SVG,
} from "src/constants";
import type {
BCIndex,
BCSettings,
Directions,
dvFrontmatterCache,
HierarchyGraphs
HierarchyGraphs,
} from "src/interfaces";
import MatrixView from "src/MatrixView";
import {
Expand All @@ -46,7 +46,7 @@ import {
mergeGs,
oppFields,
removeDuplicates,
writeBCToFile
writeBCToFile,
} from "src/sharedFunctions";
import StatsView from "src/StatsView";
import { VisModal } from "src/VisModal";
Expand Down Expand Up @@ -687,8 +687,19 @@ export default class BCPlugin extends Plugin {
const { basename } = currFile;

const { rPrev, rNext, iPrev, iNext } = getPrevNext(this, basename);
const next = [...rNext, ...iNext];
const prev = [...rPrev, ...iPrev];
// Remove duplicate implied
const next = [...rNext];
iNext.forEach((i) => {
if (next.findIndex((n) => n.to === i.to) === -1) {
next.push(i);
}
});
const prev = [...rPrev];
iPrev.forEach((i) => {
if (prev.findIndex((n) => n.to === i.to) === -1) {
prev.push(i);
}
});

const noItems =
sortedTrails.length === 0 && next.length === 0 && prev.length === 0;
Expand Down

0 comments on commit 8fc11e9

Please sign in to comment.