1- import { DatabaseCore , DB_ICONS , DEFAULT_COLUMN_CONFIG , InputType , SourceDataTypes } from "helpers/Constants" ;
1+ import { DB_ICONS , DEFAULT_COLUMN_CONFIG , InputType , SourceDataTypes } from "helpers/Constants" ;
22import DBFolderPlugin from "main" ;
33
44import {
@@ -12,6 +12,7 @@ import { LocalSettings } from "cdm/SettingsModel";
1212import { DatabaseColumn } from "cdm/DatabaseModel" ;
1313import { dbTrim } from "helpers/StylesHelper" ;
1414
15+ const projectsMetadataColumns = [ "File" , "name" , "path" ] ;
1516class ProjectAPI extends ProjectView {
1617 private plugin : DBFolderPlugin ;
1718 private view : DatabaseView ;
@@ -40,10 +41,11 @@ class ProjectAPI extends ProjectView {
4041 . values ( this . view . diskConfig . yaml . columns )
4142 . filter ( ( column ) => ! column . isMetadata ) . length ;
4243 const actualFields = fields
43- . filter ( ( field ) => ! [ DatabaseCore . FRONTMATTER_KEY , "File" ] . contains ( field . name ) ) ;
44+ . filter ( ( field ) => ! projectsMetadataColumns . contains ( field . name ) ) ;
45+
4446 if ( currentColumnsLength !== actualFields . length ) {
4547 const newColumns : Record < string , DatabaseColumn > = { } ;
46- fields . forEach ( ( field , index ) => {
48+ actualFields . forEach ( ( field , index ) => {
4749 const { name, type } = field ;
4850 /**
4951 * I can not use the view object here without make it a class variable
@@ -71,6 +73,7 @@ class ProjectAPI extends ProjectView {
7173
7274 this . view . diskConfig . yaml . columns = newColumns ;
7375 await this . view . diskConfig . saveOnDisk ( ) ;
76+ await this . view . reloadDatabase ( ) ;
7477 }
7578 }
7679
0 commit comments