Skip to content

Commit

Permalink
Add/remove TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Mar 13, 2024
1 parent 9a268c0 commit a986476
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 40 deletions.
1 change: 1 addition & 0 deletions src/components/ObsidianLink.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
on:click={() => {
// TODO: There seems to be an Obsidian issue here...
// I try to open /b from /a, but it opens /folder/b
// TODO: I think #511 comes from here. I think the third of fourth agurment should change if a second window is open
plugin.app.workspace.openLinkText(path, $active_file_store?.path ?? "");
}}
>
Expand Down
5 changes: 3 additions & 2 deletions src/components/settings/HierarchySettings.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import { debounce } from "obsidian";
import { ARROW_DIRECTIONS, DIRECTIONS } from "src/const/hierarchies";
import type BreadcrumbsPlugin from "src/main";
import { ImpliedRelationshipsSettingsModal } from "src/modals/ImpliedRelationshipsSettingsModal";
Expand Down Expand Up @@ -119,8 +120,8 @@
e.currentTarget.value,
);

// TODO: Debounce this?
await update();
// TODO: test this debounce
debounce(update, 500)();
}}
/>
</div>
Expand Down
2 changes: 0 additions & 2 deletions src/graph/builders/explicit/list_note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ const resolve_field_override = (
});
};

// TODO: Allow custom fields per list-item
// e.g. "- down [[note]]"
export const _add_explicit_edges_list_note: ExplicitEdgeBuilder = (
graph,
plugin,
Expand Down
7 changes: 4 additions & 3 deletions src/graph/builders/implied/opposite_direction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { objectify_edge_mapper } from "src/graph/objectify_mappers";
import { is_self_loop } from "src/graph/utils";
import type { ImpliedEdgeBuilder } from "src/interfaces/graph";
import { get_opposite_direction } from "src/utils/hierarchies";

Expand All @@ -16,10 +17,10 @@ export const _add_implied_edges_opposite_direction: ImpliedEdgeBuilder = (
.mapOutEdges(objectify_edge_mapper((e) => e))
.filter(
(e) =>
// NOTE: Don't need to check for a self-loop, because the implied edge would have the same edge.id as the original edge
e.attr.hierarchy_i === hierarchy_i &&
// Consider real edges & implied edges created in a previous round
(e.attr.explicit || e.attr.round < round) &&
e.attr.hierarchy_i === hierarchy_i,
// TODO: Exclude self-loops?
(e.attr.explicit || e.attr.round < round),
)
.forEach((e) => {
const opposite_direction = get_opposite_direction(e.attr.dir);
Expand Down
2 changes: 1 addition & 1 deletion src/graph/traverse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const flatten_all_paths = (paths: BCEdge[][]) => {

paths.forEach((path) => {
path.forEach((edge, depth) => {
// TODO: Check the logic of this key change
// TODO: Check the logic of this key change (I added source_id as well)
// Have we visited a target from a particular source at this depth?
const key = `${depth}-${edge.source_id}-${edge.target_id}`;

Expand Down
58 changes: 27 additions & 31 deletions src/settings/migration.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Notice } from "obsidian";
import { ListIndex } from "src/commands/list_index";
import { META_FIELD } from "src/const/metadata_fields";
import type { Hierarchy } from "src/interfaces/hierarchies";
Expand Down Expand Up @@ -110,7 +111,7 @@ export const migrate_old_settings = async (plugin: BreadcrumbsPlugin) => {
plugin.settings.explicit_edge_sources.tag_note.default_field =
old.tagNoteField;

// delete settings.tagNoteField;
delete old.tagNoteField;
}

/// List note
Expand All @@ -120,19 +121,14 @@ export const migrate_old_settings = async (plugin: BreadcrumbsPlugin) => {
old.HNUpField !== undefined
) {
if (old.hierarchyNotes.length > 0) {
console.warn(
`DEPRECATED: The central Hierarchy Notes setting is deprecated in favour of the ${META_FIELD["list-note-field"]} in each hierarchy note.`,
new Notice(
`DEPRECATED: The central Hierarchy Notes setting is deprecated in favour of the "${META_FIELD["list-note-field"]}" field in each hierarchy note.`,
);
}

// TODO: Add the list_note default settings
// plugin.settings.explicit_edge_sources.list_note = {
// exact: settings.hierarchyNoteIsParent,
// };

// delete settings.hierarchyNotes;
// delete settings.hierarchyNoteIsParent;
// delete settings.HNUpField;
delete old.HNUpField;
delete old.hierarchyNotes;
delete old.hierarchyNoteIsParent;
}

/// Dendron
Expand All @@ -149,10 +145,10 @@ export const migrate_old_settings = async (plugin: BreadcrumbsPlugin) => {
display_trimmed: old.trimDendronNotes,
};

// delete settings.addDendronNotes;
// delete settings.dendronNoteField;
// delete settings.trimDendronNotes;
// delete settings.dendronNoteDelimiter;
delete old.addDendronNotes;
delete old.dendronNoteField;
delete old.trimDendronNotes;
delete old.dendronNoteDelimiter;
}

/// Date notes
Expand All @@ -167,9 +163,9 @@ export const migrate_old_settings = async (plugin: BreadcrumbsPlugin) => {
date_format: old.dateNoteFormat,
};

// delete settings.addDateNotes;
// delete settings.dateNoteField;
// delete settings.dateNoteFormat;
delete old.addDateNotes;
delete old.dateNoteField;
delete old.dateNoteFormat;
}

// SECTION: Views
Expand All @@ -178,38 +174,38 @@ export const migrate_old_settings = async (plugin: BreadcrumbsPlugin) => {
plugin.settings.views.page.all.readable_line_width =
old.respectReadableLineLength;

// delete settings.respectReadableLineLength;
delete old.respectReadableLineLength;
}

//// Trail
if (old.showBCs !== undefined) {
plugin.settings.views.page.trail.enabled = old.showBCs;
// delete settings.showBCs;
delete old.showBCs;
}

if (old.showGrid !== undefined) {
plugin.settings.views.page.trail.format = old.showGrid
? "grid"
: "path";

// delete settings.showGrid;
delete old.showGrid;
}

if (old.gridDefaultDepth !== undefined) {
plugin.settings.views.page.trail.default_depth = old.gridDefaultDepth;
// delete settings.gridDefaultDepth;
delete old.gridDefaultDepth;
}

if (old.noPathMessage !== undefined) {
plugin.settings.views.page.trail.no_path_message = old.noPathMessage;
// delete settings.noPathMessage;
delete old.noPathMessage;
}

//// Prev/Next
if (old.showPrevNext !== undefined) {
plugin.settings.views.page.prev_next.enabled = old.showPrevNext;

// delete settings.showPrevNext;
delete old.showPrevNext;
}

// SECTION: Commands
Expand All @@ -226,9 +222,9 @@ export const migrate_old_settings = async (plugin: BreadcrumbsPlugin) => {
layout_change: old.refreshOnNoteChange,
};

// delete settings.showRefreshNotice;
// delete settings.refreshOnNoteSave;
// delete settings.refreshOnNoteChange;
delete old.showRefreshNotice;
delete old.refreshOnNoteSave;
delete old.refreshOnNoteChange;
}

/// List Index
Expand All @@ -248,17 +244,17 @@ export const migrate_old_settings = async (plugin: BreadcrumbsPlugin) => {
},
};

// delete settings.wikilinkIndex;
// delete settings.aliasesInIndex;
// delete settings.createIndexIndent;
delete old.wikilinkIndex;
delete old.aliasesInIndex;
delete old.createIndexIndent;
}

/// Freeze implied edges
if (old.writeBCsInline !== undefined) {
plugin.settings.commands.freeze_implied_edges.default_options.destination =
old.writeBCsInline ? "dataview-inline" : "frontmatter";

// delete settings.writeBCsInline;
delete old.writeBCsInline;
}

await plugin.saveSettings();
Expand Down
33 changes: 32 additions & 1 deletion tests/graph/traverse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,38 @@ describe("all_paths", () => {
]);
});

// TODO: Self-loop
test("diamond", (t) => {
const graph = new BCGraph({
edges: [
_mock_edge("a", "b", {}),
_mock_edge("b", "c", {}),
_mock_edge("b", "d", {}),
_mock_edge("c", "e", {}),
_mock_edge("d", "e", {}),
],
});

const all_paths = Traverse.all_paths("depth_first", graph, "a").map(
(path) =>
path.map((e) => ({
source_id: e.source_id,
target_id: e.target_id,
})),
);

expect(all_paths).toEqual([
[
{ source_id: "a", target_id: "b" },
{ source_id: "b", target_id: "d" },
{ source_id: "d", target_id: "e" },
],
[
{ source_id: "a", target_id: "b" },
{ source_id: "b", target_id: "c" },
{ source_id: "c", target_id: "e" },
],
]);
});

test("loop", (t) => {
const graph = new BCGraph({
Expand Down

0 comments on commit a986476

Please sign in to comment.