mirror of
https://github.com/devonthesofa/obsidian-note-status.git
synced 2026-07-22 12:30:24 +00:00
feat: add unknown icon, add multiple subscriptions
This commit is contained in:
parent
bdb8ce457f
commit
072e5e0675
5 changed files with 103 additions and 2 deletions
|
|
@ -5,17 +5,38 @@ type Props = {
|
|||
statuses: GroupedStatuses;
|
||||
onMouseEnter: (statuses: GroupedStatuses) => void;
|
||||
onMouseLeave: (statuses: GroupedStatuses) => void;
|
||||
showNoStatusIcon?: boolean;
|
||||
};
|
||||
|
||||
export const FileExplorerIcon: FC<Props> = memo(
|
||||
({ statuses, onMouseLeave, onMouseEnter }) => {
|
||||
({ statuses, onMouseLeave, onMouseEnter, showNoStatusIcon }) => {
|
||||
const statusEntries = Object.entries(statuses);
|
||||
const totalStatuses = statusEntries.reduce(
|
||||
(acc, [, list]) => acc + list.length,
|
||||
0,
|
||||
);
|
||||
|
||||
if (totalStatuses === 0) return null;
|
||||
if (totalStatuses === 0) {
|
||||
if (!showNoStatusIcon) return null;
|
||||
|
||||
// Show "no status" icon
|
||||
return (
|
||||
<div className="status-wrapper">
|
||||
<div
|
||||
className="status-minimal status-minimal--no-status"
|
||||
onMouseEnter={() => onMouseEnter({})}
|
||||
onMouseLeave={() => onMouseLeave({})}
|
||||
style={
|
||||
{
|
||||
"--primary-color": "var(--text-muted)",
|
||||
} as React.CSSProperties
|
||||
}
|
||||
>
|
||||
<span className="status-icon">❓</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const primaryStatus = statusEntries[0]?.[1]?.[0];
|
||||
if (!primaryStatus) return null;
|
||||
|
|
|
|||
|
|
@ -49,6 +49,18 @@ export class FileExplorerIntegration implements IElementProcessor {
|
|||
if (key === "fileExplorerIconPosition") {
|
||||
this.destroy();
|
||||
this.integrate().catch((r) => console.error(r));
|
||||
} else if (
|
||||
key === "showStatusIconsInExplorer" ||
|
||||
key === "hideUnknownStatusInExplorer" ||
|
||||
key === "enabledTemplates" ||
|
||||
key === "useCustomStatusesOnly" ||
|
||||
key === "customStatuses" ||
|
||||
key === "useMultipleStatuses" ||
|
||||
key === "tagPrefix" ||
|
||||
key === "strictStatuses"
|
||||
) {
|
||||
this.destroy();
|
||||
this.integrate().catch((r) => console.error(r));
|
||||
}
|
||||
},
|
||||
"fileExplorerIntegrationSubscription2",
|
||||
|
|
@ -116,6 +128,9 @@ export class FileExplorerIntegration implements IElementProcessor {
|
|||
statuses={statuses}
|
||||
onMouseEnter={(s) => this.openModalInfo(s)}
|
||||
onMouseLeave={this.closeModalInfo}
|
||||
showNoStatusIcon={
|
||||
settingsService.settings.showStatusIconsInExplorer
|
||||
}
|
||||
/>,
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -132,6 +132,23 @@ export class GroupedDashboardView extends ItemView {
|
|||
onDataChange,
|
||||
"grouped-dashboard-view-subscription",
|
||||
);
|
||||
eventBus.subscribe(
|
||||
"plugin-settings-changed",
|
||||
({ key }) => {
|
||||
if (
|
||||
key === "tagPrefix" ||
|
||||
key === "enabledTemplates" ||
|
||||
key === "useCustomStatusesOnly" ||
|
||||
key === "customStatuses" ||
|
||||
key === "useMultipleStatuses" ||
|
||||
key === "strictStatuses" ||
|
||||
key === "excludeUnknownStatus"
|
||||
) {
|
||||
onDataChange();
|
||||
}
|
||||
},
|
||||
"grouped-dashboard-view-settings-subscription",
|
||||
);
|
||||
const unsubscribeActiveFile = BaseNoteStatusService.app.workspace.on(
|
||||
"active-leaf-change",
|
||||
onDataChange,
|
||||
|
|
@ -142,6 +159,10 @@ export class GroupedDashboardView extends ItemView {
|
|||
"frontmatter-manually-changed",
|
||||
"grouped-dashboard-view-subscription",
|
||||
);
|
||||
eventBus.unsubscribe(
|
||||
"plugin-settings-changed",
|
||||
"grouped-dashboard-view-settings-subscription",
|
||||
);
|
||||
BaseNoteStatusService.app.workspace.offref(unsubscribeActiveFile);
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -117,6 +117,23 @@ export class GroupedStatusView extends ItemView {
|
|||
onDataChange,
|
||||
"grouped-status-view-subscription",
|
||||
);
|
||||
eventBus.subscribe(
|
||||
"plugin-settings-changed",
|
||||
({ key }) => {
|
||||
if (
|
||||
key === "tagPrefix" ||
|
||||
key === "enabledTemplates" ||
|
||||
key === "useCustomStatusesOnly" ||
|
||||
key === "customStatuses" ||
|
||||
key === "useMultipleStatuses" ||
|
||||
key === "strictStatuses" ||
|
||||
key === "excludeUnknownStatus"
|
||||
) {
|
||||
onDataChange();
|
||||
}
|
||||
},
|
||||
"grouped-status-view-settings-subscription",
|
||||
);
|
||||
const unsubscribeActiveFile = BaseNoteStatusService.app.workspace.on(
|
||||
"active-leaf-change",
|
||||
onDataChange,
|
||||
|
|
@ -127,6 +144,10 @@ export class GroupedStatusView extends ItemView {
|
|||
"frontmatter-manually-changed",
|
||||
"grouped-status-view-subscription",
|
||||
);
|
||||
eventBus.unsubscribe(
|
||||
"plugin-settings-changed",
|
||||
"grouped-status-view-settings-subscription",
|
||||
);
|
||||
BaseNoteStatusService.app.workspace.offref(unsubscribeActiveFile);
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -304,6 +304,25 @@ export class StatusDashboardView extends ItemView {
|
|||
handleFileChange,
|
||||
"status-dashboard-file-subscription",
|
||||
);
|
||||
eventBus.subscribe(
|
||||
"plugin-settings-changed",
|
||||
({ key }) => {
|
||||
if (
|
||||
key === "tagPrefix" ||
|
||||
key === "enabledTemplates" ||
|
||||
key === "useCustomStatusesOnly" ||
|
||||
key === "customStatuses" ||
|
||||
key === "useMultipleStatuses" ||
|
||||
key === "strictStatuses" ||
|
||||
key === "excludeUnknownStatus" ||
|
||||
key === "compactView"
|
||||
) {
|
||||
handleVaultChange();
|
||||
handleFileChange();
|
||||
}
|
||||
},
|
||||
"status-dashboard-settings-subscription",
|
||||
);
|
||||
|
||||
this.app.workspace.on("active-leaf-change", handleFileChange);
|
||||
|
||||
|
|
@ -321,6 +340,10 @@ export class StatusDashboardView extends ItemView {
|
|||
"active-file-change",
|
||||
"status-dashboard-file-subscription",
|
||||
);
|
||||
eventBus.unsubscribe(
|
||||
"plugin-settings-changed",
|
||||
"status-dashboard-settings-subscription",
|
||||
);
|
||||
|
||||
this.root?.unmount();
|
||||
this.root = null;
|
||||
|
|
|
|||
Loading…
Reference in a new issue