Skip to content

Commit

Permalink
fix: refresh data on view loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinzent03 committed Sep 11, 2024
1 parent f4354e8 commit 73d2c29
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ export function addCommmands(plugin: ObsidianGit) {
leaf = leafs.first()!;
}
app.workspace.revealLeaf(leaf);

dispatchEvent(new CustomEvent("git-refresh"));
},
});
plugin.addCommand({
Expand All @@ -74,8 +72,6 @@ export function addCommmands(plugin: ObsidianGit) {
leaf = leafs.first()!;
}
app.workspace.revealLeaf(leaf);

dispatchEvent(new CustomEvent("git-refresh"));
},
});

Expand Down
5 changes: 5 additions & 0 deletions src/ui/history/historyView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
}
}
addEventListener("git-view-refresh", refresh);
refresh();
//This should go in the onMount callback, for some reason it doesn't fire though
//setTimeout's callback will execute after the current event loop finishes.
plugin.app.workspace.onLayoutReady(() => {
Expand All @@ -39,6 +40,10 @@
}
async function refresh() {
if (!plugin.gitReady) {
logs = undefined;
return;
}
loading = true;
const isSimpleGit = plugin.gitManager instanceof SimpleGit;
logs = await plugin.gitManager.log(
Expand Down
1 change: 1 addition & 0 deletions src/ui/sourceControl/sourceControl.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
}
}
addEventListener("git-view-refresh", refresh);
refresh();
//This should go in the onMount callback, for some reason it doesn't fire though
//setTimeout's callback will execute after the current event loop finishes.
plugin.app.workspace.onLayoutReady(() => {
Expand Down

0 comments on commit 73d2c29

Please sign in to comment.