Skip to content

Commit

Permalink
setting: superDebugMode
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Jun 30, 2021
1 parent 2abae5d commit 0d45e84
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 6 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "breadcrumbs",
"name": "Breadcrumbs",
"version": "0.5.2",
"version": "0.5.3",
"minAppVersion": "0.12.7",
"description": "Visualise the hierarchy of your vault using a breadcrumb trail or matrix view",
"author": "SkepticMystic",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "breadcrumbs-plugin",
"version": "0.5.2",
"version": "0.5.3",
"description": "Visualise the hierarchy of your vault using a breadcrumb trail",
"main": "main.js",
"scripts": {
Expand Down
12 changes: 12 additions & 0 deletions src/BreadcrumbsSettingTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,5 +251,17 @@ export class BreadcrumbsSettingTab extends PluginSettingTab {
await plugin.saveSettings();
})
);

new Setting(containerEl)
.setName("Super Debug Mode")
.setDesc("Toggling this on will enable ALOT of console logs")
.addToggle((toggle) =>
toggle
.setValue(plugin.settings.superDebugMode)
.onChange(async (value) => {
plugin.settings.superDebugMode = value;
await plugin.saveSettings();
})
);
}
}
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface BreadcrumbsSettings {
trailSeperator: string;
respectReadableLineLength: boolean;
debugMode: boolean;
superDebugMode: boolean;
}

export interface neighbourObj {
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const DEFAULT_SETTINGS: BreadcrumbsSettings = {
trailSeperator: "→",
respectReadableLineLength: true,
debugMode: false,
superDebugMode: false,
};

export default class BreadcrumbsPlugin extends Plugin {
Expand Down
24 changes: 20 additions & 4 deletions src/sharedFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export function getFileFrontmatterArr(
}
app.workspace.onLayoutReady(() => {
files.forEach((file) => {
if (settings.superDebugMode) {
console.log(`Get frontmatter: ${file.basename}`);
}
const dv: FrontMatterCache = app.plugins.plugins.dataview.api.page(
file.path
);
Expand Down Expand Up @@ -58,8 +61,12 @@ export function splitAndDrop(str: string): string[] | [] {

export function getFields(
fileFrontmatter: fileFrontmatter,
field: string
field: string,
settings: BreadcrumbsSettings
): string[] {
if (settings.superDebugMode) {
console.log(`Get ${field} of: ${fileFrontmatter.file.basename}`);
}
const fieldItems: string | [] = fileFrontmatter.frontmatter[field] ?? [];

if (typeof fieldItems === "string") {
Expand Down Expand Up @@ -96,13 +103,22 @@ export function getNeighbourObjArr(
(fileFrontmatter) => {
const [parents, siblings, children] = [
parentFields
.map((parentField) => getFields(fileFrontmatter, parentField) ?? [])
.map(
(parentField) =>
getFields(fileFrontmatter, parentField, plugin.settings) ?? []
)
.flat(),
siblingFields
.map((siblingField) => getFields(fileFrontmatter, siblingField) ?? [])
.map(
(siblingField) =>
getFields(fileFrontmatter, siblingField, plugin.settings) ?? []
)
.flat(),
childFields
.map((childField) => getFields(fileFrontmatter, childField) ?? [])
.map(
(childField) =>
getFields(fileFrontmatter, childField, plugin.settings) ?? []
)
.flat(),
];
return { current: fileFrontmatter.file, parents, siblings, children };
Expand Down
1 change: 1 addition & 0 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"0.5.3": "0.12.7",
"0.5.2": "0.12.7",
"0.5.1": "0.12.7",
"0.5.0": "0.12.7",
Expand Down

0 comments on commit 0d45e84

Please sign in to comment.