Skip to content

Commit

Permalink
fix(FolderNote): 🐛 Point of to parentFolder, not previousFolder
Browse files Browse the repository at this point in the history
  • Loading branch information
SkepticMystic committed Jan 15, 2022
1 parent f75653d commit 1b9b522
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 33 deletions.
56 changes: 26 additions & 30 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3436,6 +3436,7 @@ const JUGGL_CB_DEFAULTS = {
mode: "workspace",
navigator: true,
openWithShift: false,
readContent: true,
styleGroups: [],
toolbar: true,
width: "100%",
Expand All @@ -3445,7 +3446,9 @@ const JUGGL_TRAIL_DEFAULTS = Object.assign(JUGGL_CB_DEFAULTS, {
autoZoom: true,
fdgdLayout: "d3-force",
height: "400px",
readContent: false,
toolbar: false,
navigator: false
});
CODEBLOCK_FIELDS.push(...Object.keys(JUGGL_CB_DEFAULTS));
const blankUserHier = () => {
Expand Down Expand Up @@ -5905,7 +5908,7 @@ const getClasses = function (file, metadataCache) {
}
return [CAT_DANGLING];
};
const nodeFromFile = async function (file, plugin, id) {
const nodeFromFile = async function (file, plugin, settings, id) {
if (!id) {
id = VizId.toId(file.name, CORE_STORE_ID);
}
Expand All @@ -5924,7 +5927,7 @@ const nodeFromFile = async function (file, plugin, id) {
}
catch { }
}
if (file.extension == 'md') {
if (settings.readContent && file.extension == 'md') {
data['content'] = await plugin.app.vault.cachedRead(file);
}
const frontmatter = cache?.frontmatter;
Expand Down Expand Up @@ -24177,20 +24180,20 @@ class BCStore extends obsidian.Component {
});
return Promise.resolve(edges);
}
getEvents() {
getEvents(view) {
return new BCStoreEvents();
}
getNeighbourhood(nodeId) {
// TODO
return Promise.resolve([]);
}
refreshNode(view, id) {
refreshNode(id, view) {
return;
}
storeId() {
return STORE_ID;
}
get(nodeId) {
get(nodeId, view) {
const file = this.getFile(nodeId);
if (file === null) {
const dangling = nodeDangling(nodeId.id);
Expand All @@ -24202,7 +24205,7 @@ class BCStore extends obsidian.Component {
console.log("returning empty cache", nodeId);
return Promise.resolve(nodeDangling(nodeId.id));
}
return Promise.resolve(nodeFromFile(file, this.plugin, nodeId.toId()));
return Promise.resolve(nodeFromFile(file, this.plugin, view.settings, nodeId.toId()));
}
}
function createJuggl(plugin, target, initialNodes, args) {
Expand All @@ -24225,7 +24228,7 @@ function createJuggl(plugin, target, initialNodes, args) {
console.log({ args }, { initialNodes });
const juggl = jugglPlugin.createJuggl(target, args, stores, initialNodes);
plugin.addChild(juggl);
juggl.load();
// juggl.load();
console.log({ juggl });
}
catch (error) {
Expand Down Expand Up @@ -25549,25 +25552,19 @@ function addDendronNotesToGraph(plugin, frontms, mainG) {
// Doesn't currently work yet
if (frontm[BC_IGNORE_DENDRON])
continue;
const { file } = frontm;
const basename = getDVBasename(file);
const basename = getDVBasename(frontm.file);
const splits = basename.split(dendronNoteDelimiter);
if (splits.length < 2)
if (splits.length <= 1)
continue;
// Probably inefficient to reverse then unreverse it. I can probably just use slice(-i)
const reversed = splits.reverse();
reversed.forEach((split, i) => {
const currSlice = reversed.slice(i).reverse().join(dendronNoteDelimiter);
const nextSlice = reversed
.slice(i + 1)
.reverse()
.join(dendronNoteDelimiter);
if (!nextSlice)
return;
const sourceOrder = getSourceOrder(frontm);
const targetOrder = getTargetOrder(frontms, nextSlice);
populateMain(settings, mainG, currSlice, dendronNoteField, nextSlice, sourceOrder, targetOrder, true);
});
const nextSlice = splits.slice(0, -1).join(dendronNoteDelimiter);
if (!nextSlice)
continue;
const nextSliceFile = frontms.find((fm) => getDVBasename(fm.file) === nextSlice);
if (!nextSliceFile || nextSliceFile[BC_IGNORE_DENDRON])
continue;
const sourceOrder = getSourceOrder(frontm);
const targetOrder = getTargetOrder(frontms, nextSlice);
populateMain(settings, mainG, basename, dendronNoteField, nextSlice, sourceOrder, targetOrder, true);
}
}

Expand Down Expand Up @@ -25647,7 +25644,6 @@ function addFolderNotesToGraph(plugin, folderNotes, frontms, mainG) {
const { subFolders } = getSubsFromFolder(topFolder);
const folderQueue = [...subFolders];
console.log({ startingQueue: folderQueue.slice() });
let prevFolderNote = topFolderName;
let currFolder = folderQueue.shift();
while (currFolder !== undefined) {
const { otherNotes, subFolders } = getSubsFromFolder(currFolder);
Expand All @@ -25656,7 +25652,8 @@ function addFolderNotesToGraph(plugin, folderNotes, frontms, mainG) {
// if (!isInVault(app, folderNote, folderNote)) continue;
const sourceOrder = 9999; // getSourceOrder(altFile);
const targetOrder = 9999; // getTargetOrder(frontms, basename);
populateMain(settings, mainG, prevFolderNote, field, folderNote, sourceOrder, targetOrder, true);
const parentFolderNote = currFolder.parent.name;
populateMain(settings, mainG, parentFolderNote, field, folderNote, sourceOrder, targetOrder, true);
targets.forEach((target) => {
if (target === folderNote)
return;
Expand All @@ -25667,7 +25664,6 @@ function addFolderNotesToGraph(plugin, folderNotes, frontms, mainG) {
});
folderQueue.push(...subFolders);
currFolder = folderQueue.shift();
prevFolderNote = folderNote;
}
}
// First add otherNotes to graph
Expand Down Expand Up @@ -29271,7 +29267,8 @@ class BCSettingTab extends obsidian.PluginSettingTab {
});
new obsidian.Setting(trailDetails)
.setName("Views to show")
.setDesc("Choose which of the views to show at the top of the note.\nTrail, Grid, Juggl graph and/or the Next-Previous view.")
.setDesc("Choose which of the views to show at the top of the note.\nTrail, Grid, Juggl graph and/or the Next-Previous view. " +
"Juggl requires having the Juggl plugin installed.")
.addToggle((toggle) => {
toggle
.setTooltip("Show Trail view")
Expand Down Expand Up @@ -54304,8 +54301,7 @@ class BCPlugin extends obsidian.Plugin {
}
registerLayoutChangeEvent() {
this.layoutChange = this.app.workspace.on("layout-change", async () => {
if (this.settings.showBCs)
await drawTrail(this);
// if (this.settings.showBCs) await drawTrail(this);
});
this.registerEvent(this.layoutChange);
}
Expand Down
6 changes: 3 additions & 3 deletions src/AlternativeHierarchies/FolderNotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ export function addFolderNotesToGraph(
const folderQueue: TFolder[] = [...subFolders];
console.log({ startingQueue: folderQueue.slice() });

let prevFolderNote = topFolderName;
let currFolder = folderQueue.shift();
while (currFolder !== undefined) {
const { otherNotes, subFolders } = getSubsFromFolder(currFolder);
Expand All @@ -120,10 +119,12 @@ export function addFolderNotesToGraph(
const sourceOrder = 9999; // getSourceOrder(altFile);
const targetOrder = 9999; // getTargetOrder(frontms, basename);

const parentFolderNote = currFolder.parent.name;

populateMain(
settings,
mainG,
prevFolderNote,
parentFolderNote,
field,
folderNote,
sourceOrder,
Expand Down Expand Up @@ -151,7 +152,6 @@ export function addFolderNotesToGraph(

folderQueue.push(...subFolders);
currFolder = folderQueue.shift();
prevFolderNote = folderNote;
}
}

Expand Down

0 comments on commit 1b9b522

Please sign in to comment.