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

Commit 40b6e79

Browse files
committed
improving refresh
1 parent 55e741d commit 40b6e79

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/stateManagement/data/handlers/DataviewUpdaterHandlerAction.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import { UpdaterData } from "cdm/EmitterModel";
33
import { TableColumn } from "cdm/FolderModel";
44
import { FilterSettings, LocalSettings } from "cdm/SettingsModel";
55
import { DataState, TableActionResponse } from "cdm/TableStateInterface";
6-
import { DATAVIEW_UPDATER_OPERATIONS, MetadataColumns } from "helpers/Constants";
6+
import { DATAVIEW_UPDATER_OPERATIONS, MetadataColumns, SourceDataTypes } from "helpers/Constants";
77
import tableFilter from "helpers/TableFiltersHelper";
8+
import { TFile } from "obsidian";
89
import { DataviewService } from "services/DataviewService";
910
import { LOGGER } from "services/Logger";
1011
import NoteInfo from "services/NoteInfo";
1112
import { AbstractTableAction } from "stateManagement/AbstractTableAction";
13+
import { DatabaseView } from "views/DatabaseView";
1214

1315
export default class DataviewUpdaterHandlerAction extends AbstractTableAction<DataState> {
1416
handle(tableActionResponse: TableActionResponse<DataState>): TableActionResponse<DataState> {
@@ -19,10 +21,11 @@ export default class DataviewUpdaterHandlerAction extends AbstractTableAction<Da
1921
ddbbConfig: LocalSettings,
2022
filterConfig: FilterSettings
2123
) => {
24+
25+
const { op, file, oldPath } = updaterData;
26+
if (!this.checkIfFileIsInSource(file, view)) return;
2227
set((updater) => {
2328
const { rows } = updater;
24-
const { op, file, oldPath } = updaterData;
25-
2629
const pathToOperate = oldPath ? oldPath : file.path;
2730
const indexToOperate = updater.rows.findIndex((row) => row.__note__.filepath === pathToOperate);
2831
const isFileInDDBB = indexToOperate !== -1;
@@ -78,4 +81,14 @@ export default class DataviewUpdaterHandlerAction extends AbstractTableAction<Da
7881
tableActionResponse.implementation = implementation;
7982
return this.goNext(tableActionResponse);
8083
}
84+
85+
private checkIfFileIsInSource(file: TFile, view: DatabaseView): boolean {
86+
switch (view.diskConfig.yaml.config.source_data) {
87+
case SourceDataTypes.CURRENT_FOLDER:
88+
return file.parent.path.startsWith(view.file.parent.path);
89+
case SourceDataTypes.CURRENT_FOLDER_WITHOUT_SUBFOLDERS:
90+
return file.parent.path === view.file.parent.path;
91+
}
92+
return true;
93+
}
8194
}

0 commit comments

Comments
 (0)