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

Commit 392497b

Browse files
committed
control of refreshing
1 parent fa5443e commit 392497b

File tree

11 files changed

+64
-22
lines changed

11 files changed

+64
-22
lines changed

manifest-beta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "dbfolder",
33
"name": "DB Folder",
4-
"version": "3.1.0-beta.1",
4+
"version": "3.1.0",
55
"minAppVersion": "1.1.1",
66
"description": "Folder with the capability to store and retrieve data from a folder like database",
77
"author": "RafaelGB",

manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"id": "dbfolder",
33
"name": "DB Folder",
4-
"version": "3.0.1",
5-
"minAppVersion": "0.16.3",
4+
"version": "3.1.0",
5+
"minAppVersion": "1.1.1",
66
"description": "Folder with the capability to store and retrieve data from a folder like database",
77
"author": "RafaelGB",
88
"authorUrl": "https://github.com/RafaelGB/obsidian-bd-folder",

src/cdm/SettingsModel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export interface GlobalSettings {
2929
enable_show_state: boolean;
3030
csv_file_header_key: string;
3131
enable_row_shadow: boolean;
32+
enable_auto_update: boolean;
3233
show_search_bar_by_default: boolean;
3334
}
3435

src/components/cellTypes/Editor/RelationEditor.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { RelationEditorComponentProps, SelectValue } from "cdm/ComponentsModel";
2-
import React, { useCallback, useEffect } from "react";
2+
import React, { useEffect } from "react";
33
import { useState } from "react";
44
import Select from "react-select";
55
import CustomTagsStyles from "components/styles/TagsStyles";
@@ -22,7 +22,7 @@ const RelationEditor = (props: RelationEditorComponentProps) => {
2222
? relationCell.map((link: Link) => ({
2323
label: link.fileName(),
2424
value: link.path,
25-
color: StyleVariables.TEXT_NORMAL,
25+
color: StyleVariables.BACKGROUND_SECONDARY,
2626
}))
2727
: []
2828
);
@@ -31,9 +31,9 @@ const RelationEditor = (props: RelationEditorComponentProps) => {
3131
// onChange handler
3232
const handleOnChange = async (newValue: OnChangeValue<SelectValue, true>) => {
3333
const arrayTags = newValue.map((tag) => ({
34-
label: tag.value,
34+
label: tag.label,
3535
value: tag.value,
36-
color: StyleVariables.TEXT_NORMAL,
36+
color: StyleVariables.BACKGROUND_SECONDARY,
3737
}));
3838
setRelationValue(arrayTags);
3939
};
@@ -52,6 +52,7 @@ const RelationEditor = (props: RelationEditorComponentProps) => {
5252
DEFAULT_SETTINGS.local_settings,
5353
columnsInfo.getAllColumns()
5454
);
55+
5556
const multiOptions = Object.entries(relationRows).map(([key, value]) => ({
5657
label: value,
5758
value: key,

src/components/cellTypes/Editor/filepicker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function getAliasMarkup(
3131
let container = win.document.body.createDiv(c('file-suggestion-wrapper'));
3232
container.detach();
3333

34-
setIcon(container.createDiv(c('file-suggestion-icon')), 'forward-arrow', 12);
34+
setIcon(container.createDiv(c('file-suggestion-icon')), 'forward-arrow');
3535

3636
container.createDiv({}, (div) => {
3737
div.createDiv({

src/components/tableActions/ImportCsvAction.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ export default function ImportCsvAction(actionProps: TableActionProps) {
2424
const importElement = view.addAction(
2525
"import",
2626
t("toolbar_menu_import_csv"),
27-
handleFileUpload,
28-
3
27+
handleFileUpload
2928
);
3029
view.actionButtons.import = importElement;
3130
}

src/helpers/Constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ export const DEFAULT_SETTINGS: DatabaseSettings = {
369369
enable_debug_mode: false,
370370
enable_show_state: false,
371371
enable_row_shadow: true,
372+
enable_auto_update: true,
372373
show_search_bar_by_default: false,
373374
logger_level_info: 'error',
374375
csv_file_header_key: 'File',

src/main.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -406,16 +406,18 @@ export default class DBFolderPlugin extends Plugin {
406406
/**
407407
* Once the index is ready, we can start listening for metadata changes.
408408
*/
409-
this.registerEvent(app.metadataCache.on("dataview:metadata-change",
410-
(type, file, oldPath?) => {
411-
const activeView = app.workspace.getActiveViewOfType(DatabaseView);
412-
// Iterate through all the views and reload the database if the file is the same
413-
this.viewMap.forEach(async (view) => {
414-
const isActive = activeView && (view.file.path === activeView.file.path);
415-
view.handleExternalMetadataChange(type, file, isActive, oldPath);
416-
});
417-
})
418-
);
409+
if (this.settings.global_settings.enable_auto_update) {
410+
this.registerEvent(app.metadataCache.on("dataview:metadata-change",
411+
(type, file, oldPath?) => {
412+
const activeView = app.workspace.getActiveViewOfType(DatabaseView);
413+
// Iterate through all the views and reload the database if the file is the same
414+
this.viewMap.forEach(async (view) => {
415+
const isActive = activeView && (view.file.path === activeView.file.path);
416+
view.handleExternalMetadataChange(type, file, isActive, oldPath);
417+
});
418+
})
419+
);
420+
}
419421
})
420422
);
421423
}

src/settings/HelpersSection.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { SettingHandlerResponse } from 'settings/handlers/AbstractSettingHandler
33
import { AbstractChain } from 'patterns/chain/AbstractFactoryChain';
44
import { AbstractHandler } from 'patterns/chain/AbstractHandler';
55
import { ShowSearchBarByDefaultToggleHandler } from 'settings/handlers/helpersCommands/ShowSearchBarByDefaultToggleHandler';
6+
import { EnableAutoUpdateToggleHandler } from 'settings/handlers/helpersCommands/EnableAutoUpdateTOggleHandler';
67

78
class HelpersSection extends AbstractChain<SettingHandlerResponse> {
89
protected customHandle(settingHandlerResponse: SettingHandlerResponse): SettingHandlerResponse {
@@ -14,7 +15,8 @@ class HelpersSection extends AbstractChain<SettingHandlerResponse> {
1415
}
1516
protected getHandlers(): AbstractHandler<SettingHandlerResponse>[] {
1617
return [
17-
new ShowSearchBarByDefaultToggleHandler()
18+
new ShowSearchBarByDefaultToggleHandler(),
19+
new EnableAutoUpdateToggleHandler()
1820
];
1921
}
2022
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { add_toggle } from "settings/SettingsComponents";
2+
import { AbstractSettingsHandler, SettingHandlerResponse } from "settings/handlers/AbstractSettingHandler";
3+
export class EnableAutoUpdateToggleHandler extends AbstractSettingsHandler {
4+
settingTitle: string = 'Enable Auto Update';
5+
handle(settingHandlerResponse: SettingHandlerResponse): SettingHandlerResponse {
6+
const { settingsManager, containerEl, local } = settingHandlerResponse;
7+
// pass if modal opened from local settings
8+
if (!local) {
9+
const searchbar_toggle_promise = async (value: boolean): Promise<void> => {
10+
// set debug mode
11+
const updated_global_settings = settingsManager.plugin.settings.global_settings;
12+
updated_global_settings.enable_auto_update = value;
13+
14+
// update settings
15+
await settingsManager.plugin.updateSettings({
16+
global_settings: updated_global_settings
17+
});
18+
}
19+
20+
add_toggle(
21+
containerEl,
22+
this.settingTitle,
23+
"Enable auto update listener from other files. WARNING: requires restart to take effect.",
24+
settingsManager.plugin.settings.global_settings.enable_auto_update,
25+
searchbar_toggle_promise
26+
);
27+
}
28+
29+
return this.goNext(settingHandlerResponse);
30+
}
31+
}

0 commit comments

Comments
 (0)