@@ -3,12 +3,14 @@ import { UpdaterData } from "cdm/EmitterModel";
33import { TableColumn } from "cdm/FolderModel" ;
44import { FilterSettings , LocalSettings } from "cdm/SettingsModel" ;
55import { DataState , TableActionResponse } from "cdm/TableStateInterface" ;
6- import { DATAVIEW_UPDATER_OPERATIONS , MetadataColumns } from "helpers/Constants" ;
6+ import { DATAVIEW_UPDATER_OPERATIONS , MetadataColumns , SourceDataTypes } from "helpers/Constants" ;
77import tableFilter from "helpers/TableFiltersHelper" ;
8+ import { TFile } from "obsidian" ;
89import { DataviewService } from "services/DataviewService" ;
910import { LOGGER } from "services/Logger" ;
1011import NoteInfo from "services/NoteInfo" ;
1112import { AbstractTableAction } from "stateManagement/AbstractTableAction" ;
13+ import { DatabaseView } from "views/DatabaseView" ;
1214
1315export 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