mirror of
https://github.com/shumadrid/obsidian-git-changelog.git
synced 2026-07-22 05:42:16 +00:00
fix: empty the file changelog view if no DiffViews are visible
This commit is contained in:
parent
4f55251839
commit
e58a981253
8 changed files with 49 additions and 43 deletions
39
package-lock.json
generated
39
package-lock.json
generated
|
|
@ -1413,9 +1413,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@eslint-community/eslint-utils": {
|
||||
"version": "4.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.5.1.tgz",
|
||||
"integrity": "sha512-soEIOALTfTK6EjmKMMoLugwaP0rzkad90iIWd1hMO9ARkSAyjfMfkRRhLvD5qH7vvM0Cg72pieUfR6yh6XxC4w==",
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.6.0.tgz",
|
||||
"integrity": "sha512-WhCn7Z7TauhBtmzhvKpoQs0Wwb/kBcy4CwpuI0/eEIr2Lx2auxmulAzLr91wVZJaz47iUZdkXOK7WlAfxGKCnA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
|
@ -5645,15 +5645,15 @@
|
|||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-import-x": {
|
||||
"version": "4.10.2",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-import-x/-/eslint-plugin-import-x-4.10.2.tgz",
|
||||
"integrity": "sha512-jO3Y6+zBUyTX5MVbbLSzoz6fe65t+WEBaXStRLM4EBhZWbuSwAH3cLwARtM0Yp4zRtZGp9sL2zzK7G9JkHR8LA==",
|
||||
"version": "4.10.3",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-import-x/-/eslint-plugin-import-x-4.10.3.tgz",
|
||||
"integrity": "sha512-Q7yx76tlOfzLGtXDt/sppdYrGNcbr9CrRXqJXTNIpM/7hfX9lRp1noE+PkYgN+xvW47TEeGZ0pgy29hlX9Y7UQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@pkgr/core": "^0.2.1",
|
||||
"@pkgr/core": "^0.2.2",
|
||||
"@types/doctrine": "^0.0.9",
|
||||
"@typescript-eslint/utils": "^8.29.0",
|
||||
"@typescript-eslint/utils": "^8.29.1",
|
||||
"debug": "^4.4.0",
|
||||
"doctrine": "^3.0.0",
|
||||
"eslint-import-resolver-node": "^0.3.9",
|
||||
|
|
@ -5663,11 +5663,14 @@
|
|||
"semver": "^7.7.1",
|
||||
"stable-hash": "^0.0.5",
|
||||
"tslib": "^2.8.1",
|
||||
"unrs-resolver": "^1.4.1"
|
||||
"unrs-resolver": "^1.5.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/eslint-plugin-import-x"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^8.57.0 || ^9.0.0"
|
||||
}
|
||||
|
|
@ -8980,9 +8983,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/obsidian-dev-utils": {
|
||||
"version": "26.1.0",
|
||||
"resolved": "https://registry.npmjs.org/obsidian-dev-utils/-/obsidian-dev-utils-26.1.0.tgz",
|
||||
"integrity": "sha512-2GLQa/J1Uk6+9VmHZMXfyiPB974Ug4TAv/qRHx8xVOZaviL/VwuxVXS0W7qirRu8ojGkkkhhWE3li5RwDZgWYg==",
|
||||
"version": "26.1.2",
|
||||
"resolved": "https://registry.npmjs.org/obsidian-dev-utils/-/obsidian-dev-utils-26.1.2.tgz",
|
||||
"integrity": "sha512-FaYuMyHfxqU8a57OJwc6WVIZWkH7iGJBZ+wLW0YsojMP9qFK86SxSy3eBat7fBVVC3euvui9RpBPI2GsS0Jh0Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
|
@ -11361,9 +11364,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/svelte": {
|
||||
"version": "5.26.1",
|
||||
"resolved": "https://registry.npmjs.org/svelte/-/svelte-5.26.1.tgz",
|
||||
"integrity": "sha512-Hhhb7cV9il0wMWOjjf+HVyr50XdKSP/tXX6JaO4l25+sV4XsO4lA/bo/vrdbBd0f1qB48IEwJgbebi0u4rA9vA==",
|
||||
"version": "5.26.2",
|
||||
"resolved": "https://registry.npmjs.org/svelte/-/svelte-5.26.2.tgz",
|
||||
"integrity": "sha512-e2TEcGK2YKVwDWYy5OsptVclYgDvfY1E/8IzPiOq63uG/GDo/j5VUYTC9EinQNraoZalbMWN+5f5TYC1QlAqOw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
|
@ -11387,9 +11390,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/svelte-check": {
|
||||
"version": "4.1.5",
|
||||
"resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-4.1.5.tgz",
|
||||
"integrity": "sha512-Gb0T2IqBNe1tLB9EB1Qh+LOe+JB8wt2/rNBDGvkxQVvk8vNeAoG+vZgFB/3P5+zC7RWlyBlzm9dVjZFph/maIg==",
|
||||
"version": "4.1.6",
|
||||
"resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-4.1.6.tgz",
|
||||
"integrity": "sha512-P7w/6tdSfk3zEVvfsgrp3h3DFC75jCdZjTQvgGJtjPORs1n7/v2VMPIoty3PWv7jnfEm3x0G/p9wH4pecTb0Wg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import { runHashObjectEmptyTree } from 'core/gitOperations/runHashObjectEmptyTre
|
|||
import { changelogGenerationSettingsChanged } from 'core/helper.ts';
|
||||
import { VaultChangelogManager } from 'core/VaultChangelogManager.ts';
|
||||
import { addContextMenuItems } from 'menu.ts';
|
||||
import { debounce, ItemView, Notice } from 'obsidian';
|
||||
import { debounce, Notice } from 'obsidian';
|
||||
import { PluginBase } from 'obsidian-dev-utils/obsidian/Plugin/PluginBase';
|
||||
import { GitChangelogSettingsManager } from 'settings/settingsManager.ts';
|
||||
import { getLocaleToAssign } from 'settings/ui/CustomLocale.ts';
|
||||
|
|
@ -35,7 +35,7 @@ import {
|
|||
FILE_CHANGELOG_VIEW_CONFIG,
|
||||
FileChangelogView
|
||||
} from 'Views/FileChangelog/FileChangelog.ts';
|
||||
import { getActiveGitRelativeFile, isDiffView } from 'Views/helper.ts';
|
||||
import { getActiveGitRelativeFile, isDiffViewVisible } from 'Views/helper.ts';
|
||||
import {
|
||||
VAULT_CHANGELOG_VIEW_CONFIG,
|
||||
VaultChangelogView
|
||||
|
|
@ -288,7 +288,7 @@ export class GitChangelogPlugin extends PluginBase<GitChangelogPluginTypes> {
|
|||
}
|
||||
|
||||
this.registerEvent(
|
||||
this.app.workspace.on('file-open', () => {
|
||||
this.app.workspace.on('active-leaf-change', () => {
|
||||
this.updateActiveGitFile();
|
||||
})
|
||||
);
|
||||
|
|
@ -371,19 +371,16 @@ export class GitChangelogPlugin extends PluginBase<GitChangelogPluginTypes> {
|
|||
|
||||
if (currentActiveGitFile) {
|
||||
this.setNewActiveGitFile(currentActiveGitFile);
|
||||
} else {
|
||||
const currentActiveView =
|
||||
this.app.workspace.getActiveViewOfType(ItemView);
|
||||
|
||||
// If a DiffView is active, don't clear the active git file, but keep it, so that the file changelog still shows stats for that previously active file. Only works if the diff view is also focused.
|
||||
if (isDiffView(currentActiveView)) {
|
||||
return;
|
||||
}
|
||||
|
||||
} else if (
|
||||
!isDiffViewVisible({
|
||||
app: this.app
|
||||
})
|
||||
) {
|
||||
// If a DiffView is visible, don't clear the active git file, but keep it, so that the file changelog still shows stats for that previously active file.
|
||||
this.setNewActiveGitFile(undefined);
|
||||
}
|
||||
} catch {
|
||||
/* Empty */
|
||||
/* Just do nothing */
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,8 +66,8 @@ export class CompareRepoCommitsView
|
|||
this._view = mount(CompareRepoCommitsComponent, {
|
||||
props: {
|
||||
plugin: this.plugin,
|
||||
closeView: async () => {
|
||||
await this.close();
|
||||
closeView: () => {
|
||||
// Await this.close();
|
||||
removeCompareVersionsView(this.plugin);
|
||||
},
|
||||
utcOlderDate: this.utcOlderDate,
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@ export class CompareToCheckpointView extends ItemView {
|
|||
this._view = mount(CompareToCheckpointComponent, {
|
||||
props: {
|
||||
plugin: this.plugin,
|
||||
closeView: async () => {
|
||||
await this.close();
|
||||
closeView: () => {
|
||||
// Await this.close();
|
||||
removeCompareVersionsView(this.plugin);
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { ItemView } from 'obsidian';
|
||||
import type { App, ItemView } from 'obsidian';
|
||||
|
||||
import { MarkdownView, TFile } from 'obsidian';
|
||||
import { getNewLeaf } from 'utils.ts';
|
||||
|
|
@ -87,11 +87,18 @@ export function getDisplayPath(path: string): string {
|
|||
return path.split('/').last()?.replace(/\.md$/, '') ?? '';
|
||||
}
|
||||
|
||||
export function isDiffView(view: ItemView | null): boolean {
|
||||
return (
|
||||
view?.getViewType() === 'diff-view' ||
|
||||
view?.getViewType() === 'split-diff-view'
|
||||
);
|
||||
/**
|
||||
* Assumes that no file view is currently active
|
||||
*/
|
||||
export function isDiffViewVisible({ app }: { app: App }): boolean {
|
||||
const diffViews = [
|
||||
...app.workspace.getLeavesOfType('diff-view'),
|
||||
...app.workspace.getLeavesOfType('split-diff-view')
|
||||
];
|
||||
|
||||
return diffViews.some((leaf) => {
|
||||
return leaf.containerEl.isShown();
|
||||
});
|
||||
}
|
||||
|
||||
export function openFile({
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import {
|
|||
import { CssClass } from 'obsidian-dev-utils/CssClass';
|
||||
import { showModal } from 'obsidian-dev-utils/obsidian/Modals/ModalBase';
|
||||
import { removeCompareVersionsView } from 'utils.ts';
|
||||
import { CompareVersionsModal } from 'Views/CompareRepoCommits/PrepareCompareModal.ts';
|
||||
import { CompareVersionsModal } from 'Views/CompareRepoCommits/CompareModal.ts';
|
||||
import { FILE_CHANGELOG_VIEW_CONFIG } from 'Views/FileChangelog/FileChangelog.ts';
|
||||
import { VAULT_CHANGELOG_VIEW_CONFIG } from 'Views/VaultChangelog/VaultChangelog.ts';
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ export class DayStartHour extends SettingComponent {
|
|||
text.setValue(moment.duration(value, 'hours'));
|
||||
},
|
||||
shouldShowValidationMessage: false,
|
||||
shouldResetSettingWhenComponentIsEmpty: false,
|
||||
pluginSettingsToComponentValueConverter: (
|
||||
pluginSettingsValue: number
|
||||
) => moment.duration(pluginSettingsValue, 'hours')
|
||||
|
|
|
|||
Loading…
Reference in a new issue