diff --git a/api/src/main/java/telegram/files/HttpVerticle.java b/api/src/main/java/telegram/files/HttpVerticle.java index 935ec4c..8c3ec53 100644 --- a/api/src/main/java/telegram/files/HttpVerticle.java +++ b/api/src/main/java/telegram/files/HttpVerticle.java @@ -145,10 +145,9 @@ public class HttpVerticle extends AbstractVerticle { return; } Throwable throwable = ctx.failure(); - log.error("route: %s statusCode: %d Error: %s".formatted( + log.error("route: %s statusCode: %d".formatted( ctx.currentRoute().getName(), - statusCode, - throwable == null ? "" : throwable.getMessage())); + statusCode), throwable); HttpServerResponse response = ctx.response(); response.setStatusCode(statusCode) .putHeader("Content-Type", "application/json") diff --git a/api/src/main/java/telegram/files/repository/SettingKey.java b/api/src/main/java/telegram/files/repository/SettingKey.java index 730e367..d3cd407 100644 --- a/api/src/main/java/telegram/files/repository/SettingKey.java +++ b/api/src/main/java/telegram/files/repository/SettingKey.java @@ -6,10 +6,10 @@ import io.vertx.core.json.JsonObject; import java.util.function.Function; public enum SettingKey { - uniqueOnly(Convert::toBool), - needToLoadImages(Convert::toBool), + uniqueOnly(Convert::toBool, false), + needToLoadImages(Convert::toBool, false), imageLoadSize, - showSensitiveContent(Convert::toBool), + showSensitiveContent(Convert::toBool, false), autoDownload(value -> new JsonObject(value).mapTo(SettingAutoRecords.class)), /** * Auto download limit for each telegram account @@ -19,11 +19,18 @@ public enum SettingKey { public final Function converter; + public final Object defaultValue; + SettingKey() { - this.converter = Function.identity(); + this(Function.identity(), null); } SettingKey(Function converter) { + this(converter, null); + } + + SettingKey(Function converter, Object defaultValue) { this.converter = converter; + this.defaultValue = defaultValue; } } diff --git a/api/src/main/java/telegram/files/repository/impl/SettingRepositoryImpl.java b/api/src/main/java/telegram/files/repository/impl/SettingRepositoryImpl.java index febd613..f30b9f7 100644 --- a/api/src/main/java/telegram/files/repository/impl/SettingRepositoryImpl.java +++ b/api/src/main/java/telegram/files/repository/impl/SettingRepositoryImpl.java @@ -93,7 +93,7 @@ public class SettingRepositoryImpl implements SettingRepository { if (rs.size() == 1) { return (T) key.converter.apply(rs.iterator().next()); } - return null; + return key.defaultValue == null ? null : (T) key.defaultValue; }) .onSuccess(r -> log.debug("Successfully fetched setting record for key: " + key)) .onFailure( diff --git a/web/src/components/settings-dialog.tsx b/web/src/components/settings-dialog.tsx index 3f429d6..159e2db 100644 --- a/web/src/components/settings-dialog.tsx +++ b/web/src/components/settings-dialog.tsx @@ -13,7 +13,7 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select"; -import {Bell, Settings} from "lucide-react"; +import { Bell, Settings } from "lucide-react"; import { Label } from "@/components/ui/label"; import { Checkbox } from "@/components/ui/checkbox"; import { VisuallyHidden } from "@radix-ui/react-visually-hidden"; @@ -79,104 +79,108 @@ export const SettingsDialog: React.FC = () => { className="flex flex-col overflow-hidden" >
-

- - These settings will be applied to all accounts. -

-
-
- - - void setSetting("uniqueOnly", String(checked)) - } - /> -
-

- Show only unique file in the table. If disabled, will show - all.
- Warning: If enabled, the number of documents - on the form will be inaccurate. +

+

+ + These settings will be applied to all accounts.

-
-
-
- - { - void setSetting("needToLoadImages", String(checked)); - }} - /> -
- {settings?.needToLoadImages === "true" && ( -
- - -

- The size of the image to load in the browser. -

+
+
+ + + void setSetting("uniqueOnly", String(checked)) + } + />
- )} -
-
-
- - - void setSetting("showSensitiveContent", String(checked)) - } - /> +

+ Show only unique file in the table. If disabled, will show + all.
+ Warning: If enabled, the number of + documents on the form will be inaccurate. +

-

- Show sensitive content in the table, Will use a spoiler to - hide sensitive content if disabled. -

-
-
- -
- - { - void setSetting("autoDownloadLimit", e.target.value); - }} - /> +
+
+ + { + void setSetting("needToLoadImages", String(checked)); + }} + /> +
+ {settings?.needToLoadImages === "true" && ( +
+ + +

+ The size of the image to load in the browser. +

+
+ )}
+
+
+ + + void setSetting("showSensitiveContent", String(checked)) + } + /> +
+

+ Show sensitive content in the table, Will use a spoiler to + hide sensitive content if disabled. +

+
+
+ +
+ + { + void setSetting("autoDownloadLimit", e.target.value); + }} + /> +
+
+
+
+
-
- -