summaryrefslogtreecommitdiffhomepage
path: root/src/features/settings/logic/view-model.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-27 01:13:28 +0900
committerAdam Malczewski <[email protected]>2026-06-27 01:13:31 +0900
commit0a271e3e8aecb1ec9db3eea873b3df1ecaab8b99 (patch)
tree0a5a6e62acf2d8e15ec69fd09f641cd75a1bcb10 /src/features/settings/logic/view-model.ts
parent397ce9b65b888121d8c7e909c37dfdbffe914673 (diff)
parent576f539670f406280f8398abf78a867d70b683b8 (diff)
downloaddispatch-web-0a271e3e8aecb1ec9db3eea873b3df1ecaab8b99.tar.gz
dispatch-web-0a271e3e8aecb1ec9db3eea873b3df1ecaab8b99.zip
Merge branch 'dev' into feature/heartbeat
# Conflicts: # src/app/App.svelte # src/app/store.svelte.ts # src/app/store.test.ts # src/features/workspaces/ui/WorkspaceCard.test.ts
Diffstat (limited to 'src/features/settings/logic/view-model.ts')
-rw-r--r--src/features/settings/logic/view-model.ts32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/features/settings/logic/view-model.ts b/src/features/settings/logic/view-model.ts
index caf76ee..73f6d17 100644
--- a/src/features/settings/logic/view-model.ts
+++ b/src/features/settings/logic/view-model.ts
@@ -17,8 +17,8 @@ import { normalizeChatLimit } from "../../../core/chunks";
/** Outcome of persisting a chat-limit setting. */
export type ChatLimitSaveResult =
- | { readonly ok: true; readonly chatLimit: number }
- | { readonly ok: false; readonly error: string };
+ | { readonly ok: true; readonly chatLimit: number }
+ | { readonly ok: false; readonly error: string };
export type SaveChatLimit = (value: number) => Promise<ChatLimitSaveResult>;
@@ -26,8 +26,8 @@ export type SaveChatLimit = (value: number) => Promise<ChatLimitSaveResult>;
/** Result of parsing a typed chat-limit string. */
export type ChatLimitParse =
- | { readonly ok: true; readonly value: number }
- | { readonly ok: false; readonly error: string };
+ | { readonly ok: true; readonly value: number }
+ | { readonly ok: false; readonly error: string };
/**
* Parse a typed chat-limit string into a normalized limit (floored + clamped to
@@ -37,15 +37,15 @@ export type ChatLimitParse =
* from user typing.
*/
export function parseChatLimit(raw: string): ChatLimitParse {
- const trimmed = raw.trim();
- if (trimmed.length === 0) {
- return { ok: false, error: "Enter a number." };
- }
- const n = Number(trimmed);
- if (!Number.isFinite(n)) {
- return { ok: false, error: "Must be a number." };
- }
- return { ok: true, value: normalizeChatLimit(n) };
+ const trimmed = raw.trim();
+ if (trimmed.length === 0) {
+ return { ok: false, error: "Enter a number." };
+ }
+ const n = Number(trimmed);
+ if (!Number.isFinite(n)) {
+ return { ok: false, error: "Must be a number." };
+ }
+ return { ok: true, value: normalizeChatLimit(n) };
}
/**
@@ -54,7 +54,7 @@ export function parseChatLimit(raw: string): ChatLimitParse {
* dirty-check for the input — it must NOT mutate or clamp, only compare.
*/
export function chatLimitChanged(typed: string, current: number): boolean {
- const parsed = parseChatLimit(typed);
- if (!parsed.ok) return false;
- return parsed.value !== current;
+ const parsed = parseChatLimit(typed);
+ if (!parsed.ok) return false;
+ return parsed.value !== current;
}