Fix checkbox state not updating + ran prettier

Forgot a comma and to load back the wikilink with new properties
This commit is contained in:
ltctceplrm 2025-12-09 21:07:45 +01:00
parent 95035e5eac
commit f8b6ae8761
6 changed files with 18 additions and 16 deletions

View file

@ -584,7 +584,9 @@ export default class MediaDbPlugin extends Plugin {
newProperties.push(defaultProperty);
} else {
// newProperty is just an object and take locked status from default property
newProperties.push(new PropertyMapping(newProperty.property, newProperty.newProperty, newProperty.mapping, defaultProperty.locked));
newProperties.push(
new PropertyMapping(newProperty.property, newProperty.newProperty, newProperty.mapping, defaultProperty.locked, newProperty.wikilink ?? false),
);
}
}

View file

@ -40,9 +40,7 @@ export class PropertyMapper {
if (typeof value === 'string') {
finalValue = `[[${value}]]`;
} else if (Array.isArray(value)) {
finalValue = value.map(v =>
typeof v === 'string' ? `[[${v}]]` : v
);
finalValue = value.map(v => (typeof v === 'string' ? `[[${v}]]` : v));
}
}
if (propertyMapping.mapping === PropertyMappingOption.Map) {

View file

@ -71,11 +71,11 @@
</div>
<style>
.media-db-plugin-property-mapping-wikilink-label {
display: flex;
align-items: center;
gap: 4px;
font-size: 0.95em;
cursor: pointer;
}
.media-db-plugin-property-mapping-wikilink-label {
display: flex;
align-items: center;
gap: 4px;
font-size: 0.95em;
cursor: pointer;
}
</style>

View file

@ -162,7 +162,7 @@ export function getDefaultSettings(plugin: MediaDbPlugin): MediaDbPluginSettings
PropertyMappingOption.Default,
lockedPropertyMappings.contains(key),
false, // wikilink default
)
),
);
}
@ -817,8 +817,8 @@ export class MediaDbSettingTab extends PluginSettingTab {
cb.setPlaceholder(`Example: ${DEFAULT_SETTINGS.boardgameFileNameTemplate}`)
.setValue(this.plugin.settings.boardgameFileNameTemplate)
.onChange(data => {
this.plugin.settings.boardgameFileNameTemplate = data;
void this.plugin.saveSettings();
this.plugin.settings.boardgameFileNameTemplate = data;
void this.plugin.saveSettings();
});
});

View file

@ -5,7 +5,8 @@ export class FileSuggest extends AbstractInputSuggest<TFile> {
const lowerCaseInputStr = query.toLowerCase();
// we do two filters because otherwise TS type inference does convert the array to TFile[]
return this.app.vault.getAllLoadedFiles()
return this.app.vault
.getAllLoadedFiles()
.filter(file => file instanceof TFile)
.filter(file => file.path.toLowerCase().contains(lowerCaseInputStr));
}

View file

@ -5,7 +5,8 @@ export class FolderSuggest extends AbstractInputSuggest<TFolder> {
const lowerCaseInputStr = query.toLowerCase();
// we do two filters because otherwise TS type inference does convert the array to TFolder[]
return this.app.vault.getAllLoadedFiles()
return this.app.vault
.getAllLoadedFiles()
.filter(file => file instanceof TFolder)
.filter(file => file.path.toLowerCase().contains(lowerCaseInputStr));
}