Change file limit from slider to number

This commit is contained in:
Andras Schmelczer 2025-05-24 13:56:36 +01:00
commit 22a13e0152
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C

View file

@ -297,15 +297,28 @@ export class SyncSettingsTab extends PluginSettingTab {
.setDesc( .setDesc(
"Set the maximum file size that can be uploaded to the server. Files larger than this size will be ignored." "Set the maximum file size that can be uploaded to the server. Files larger than this size will be ignored."
) )
.addSlider((slider) => .addText((input) =>
slider input
.setLimits(1, 64, 1) .setValue(
.setDynamicTooltip() this.syncClient.getSettings().maxFileSizeMB.toString()
.setInstant(false)
.setValue(this.syncClient.getSettings().maxFileSizeMB)
.onChange(async (value) =>
this.syncClient.setSetting("maxFileSizeMB", value)
) )
.onChange(async (value) => {
if (value === "") {
return;
}
let parsedValue = Number.parseFloat(value);
if (Number.isNaN(parsedValue) || parsedValue < 0) {
parsedValue =
this.syncClient.getSettings().maxFileSizeMB;
}
this.syncClient.setSetting(
"maxFileSizeMB",
parsedValue
);
if (value !== parsedValue.toString()) {
input.setValue(parsedValue.toString());
}
})
); );
new Setting(containerEl) new Setting(containerEl)