Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 995ec7c

Browse files
committed
correction filters
1 parent 2a0a1fd commit 995ec7c

File tree

6 files changed

+19
-13
lines changed

6 files changed

+19
-13
lines changed

src/DatabaseView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ export class DatabaseView extends TextFileView implements HoverParent {
192192
destroy() {
193193
LOGGER.info(`=>destroy ${this.file.path}`);
194194
// Remove draggables from render, as the DOM has already detached
195+
this.getStateManager().unregisterView(this);
195196
this.plugin.removeView(this);
196197
this.tableContainer.remove();
197198
LOGGER.info(`<=destroy ${this.file.path}`);

src/StateManager.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ export default class StateManager {
1919
}
2020

2121
registerView(view: DatabaseView) {
22-
this.viewSet.clear();
23-
this.viewSet.add(view);
24-
view.initDatabase();
25-
22+
if (!this.viewSet.has(view)) {
23+
this.viewSet.add(view);
24+
view.initDatabase();
25+
}
2626
}
2727

2828
unregisterView(view: DatabaseView) {

src/cdm/TableStateInterface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface ConfigState {
2424
filters: FilterSettings;
2525
global: GlobalSettings;
2626
actions: {
27-
alterFilters: (filters: Partial<FilterSettings>) => void;
27+
alterFilters: (filters: Partial<FilterSettings>) => Promise<void>;
2828
alterConfig: (config: Partial<LocalSettings>) => void;
2929
}
3030
info: {

src/components/portals/DataviewFiltersPortal.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ import MenuUpIcon from "components/img/MenuUpIcon";
2222
const DataviewFiltersPortal = (props: DataviewFiltersProps) => {
2323
const { table } = props;
2424
const { tableState, view } = table.options.meta;
25-
const [ddbbConfig, filters, configActions] = tableState.configState(
26-
(state) => [state.ddbbConfig, state.filters, state.actions]
27-
);
28-
25+
const [ddbbConfig, configActions] = tableState.configState((state) => [
26+
state.ddbbConfig,
27+
state.actions,
28+
]);
29+
const filters = tableState.configState((state) => state.filters);
2930
const columns = tableState.columns((state) => state.columns);
3031
const dataActions = tableState.data((state) => state.actions);
3132
const [filtersRef, setFiltersRef] = useState(null);

src/main.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export default class DBFolderPlugin extends Plugin {
9393

9494
this.registerView(DatabaseCore.FRONTMATTER_KEY, (leaf) => new DatabaseView(leaf, this));
9595
this.registerEvents();
96+
this.registerCommands();
9697
this.registerMonkeyPatches();
9798
this.addMarkdownPostProcessor();
9899
// Mount an empty component to start; views will be added as we go
@@ -417,7 +418,9 @@ export default class DBFolderPlugin extends Plugin {
417418
})
418419
);
419420
}
420-
421+
registerCommands() {
422+
// TODO - add command to create a new database
423+
}
421424
/**
422425
* Displays a transcluded .excalidraw image in markdown preview mode
423426
*/

src/stateManagement/useConfigStore.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ const useConfigStore = (view: DatabaseView) => {
1212
filters: filters,
1313
global: global_settings,
1414
actions: {
15-
alterFilters: (partialFilters: Partial<FilterSettings>) =>
15+
alterFilters: async (partialFilters: Partial<FilterSettings>) => {
16+
await view.diskConfig.updateFilters(partialFilters);
1617
set((state) => {
17-
view.diskConfig.updateFilters(partialFilters);
1818
return ({ filters: { ...state.filters, ...partialFilters } });
19-
}),
19+
})
20+
},
2021
alterConfig: (alteredConfig: Partial<LocalSettings>) =>
2122
set((state) => {
2223
view.diskConfig.updateConfig(alteredConfig);

0 commit comments

Comments
 (0)