Skip to content

Build your personal knowledge base with Trilium Notes

chore(react/settings): solve type errors

Elian Dorancbc9fb7d08d2
diff --git a/apps/client/src/widgets/dialogs/bulk_actions.tsx b/apps/client/src/widgets/dialogs/bulk_actions.tsx
index 3156d0d88a..8d184433fc 100644
--- a/apps/client/src/widgets/dialogs/bulk_actions.tsx
+++ b/apps/client/src/widgets/dialogs/bulk_actions.tsx
@@ -94,7 +94,8 @@ function AvailableActionsList() {
<td>{ actionGroup.title }:</td>
{actionGroup.actions.map(({ actionName, actionTitle }) =>
<Button
- small text={actionTitle}
+ size="small"
+ text={actionTitle}
onClick={() => bulk_action.addAction("_bulkAction", actionName)}
/>
)}
diff --git a/apps/client/src/widgets/dialogs/recent_changes.tsx b/apps/client/src/widgets/dialogs/recent_changes.tsx
index 90dc99f544..264d2f15de 100644
--- a/apps/client/src/widgets/dialogs/recent_changes.tsx
+++ b/apps/client/src/widgets/dialogs/recent_changes.tsx
@@ -57,7 +57,8 @@ function RecentChangesDialogComponent() {
header={
<Button
text={t("recent_changes.erase_notes_button")}
- small style={{ padding: "0 10px" }}
+ size="small"
+ style={{ padding: "0 10px" }}
onClick={() => {
server.post("notes/erase-deleted-notes-now").then(() => {
setNeedsRefresh(true);
diff --git a/apps/client/src/widgets/dialogs/revisions.tsx b/apps/client/src/widgets/dialogs/revisions.tsx
index f5e0b203d1..4d6377bba2 100644
--- a/apps/client/src/widgets/dialogs/revisions.tsx
+++ b/apps/client/src/widgets/dialogs/revisions.tsx
@@ -55,7 +55,7 @@ function RevisionsDialogComponent() {
helpPageId="vZWERwf8U3nx"
bodyStyle={{ display: "flex", height: "80vh" }}
header={
- (!!revisions?.length && <Button text={t("revisions.delete_all_revisions")} small style={{ padding: "0 10px" }}
+ (!!revisions?.length && <Button text={t("revisions.delete_all_revisions")} size="small" style={{ padding: "0 10px" }}
onClick={async () => {
const text = t("revisions.confirm_delete_all");
diff --git a/apps/client/src/widgets/react/FormTextBox.tsx b/apps/client/src/widgets/react/FormTextBox.tsx
index f80bbf444f..6fde90f629 100644
--- a/apps/client/src/widgets/react/FormTextBox.tsx
+++ b/apps/client/src/widgets/react/FormTextBox.tsx
@@ -1,6 +1,6 @@
import type { InputHTMLAttributes, RefObject } from "preact/compat";
-interface FormTextBoxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "onChange" | "value"> {
+interface FormTextBoxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "onChange" | "onBlur" | "value"> {
id?: string;
currentValue?: string;
onChange?(newValue: string, validity: ValidityState): void;
diff --git a/apps/client/src/widgets/type_widgets/options/shortcuts.tsx b/apps/client/src/widgets/type_widgets/options/shortcuts.tsx
index f6d22d960f..91c26179e6 100644
--- a/apps/client/src/widgets/type_widgets/options/shortcuts.tsx
+++ b/apps/client/src/widgets/type_widgets/options/shortcuts.tsx
@@ -27,7 +27,7 @@ export default function ShortcutSettings() {
return;
}
- let updatedShortcuts: KeyboardShortcut[] = null;
+ let updatedShortcuts: (KeyboardShortcut[] | null) = null;
for (const optionName of optionNames) {
if (!(optionName.startsWith("keyboardShortcuts"))) {
@@ -58,12 +58,13 @@ export default function ShortcutSettings() {
const optionsToSet: Record<string, string> = {};
for (const keyboardShortcut of keyboardShortcuts) {
- if (!("effectiveShortcuts" in keyboardShortcut)) {
+ if (!("effectiveShortcuts" in keyboardShortcut) || !keyboardShortcut.effectiveShortcuts) {
continue;
}
- if (!arrayEqual(keyboardShortcut.effectiveShortcuts, keyboardShortcut.defaultShortcuts)) {
- optionsToSet[getOptionName(keyboardShortcut.actionName)] = JSON.stringify(keyboardShortcut.defaultShortcuts);
+ const defaultShortcuts = keyboardShortcut.defaultShortcuts ?? [];
+ if (!arrayEqual(keyboardShortcut.effectiveShortcuts, defaultShortcuts)) {
+ optionsToSet[getOptionName(keyboardShortcut.actionName)] = JSON.stringify(defaultShortcuts);
}
}
options.saveMany(optionsToSet);
diff --git a/apps/client/src/widgets/type_widgets/options/sync.tsx b/apps/client/src/widgets/type_widgets/options/sync.tsx
index c197281536..2146ab7c1e 100644
--- a/apps/client/src/widgets/type_widgets/options/sync.tsx
+++ b/apps/client/src/widgets/type_widgets/options/sync.tsx
@@ -83,7 +83,7 @@ export function SyncTest() {
onClick={async () => {
const result = await server.post<SyncTestResponse>("sync/test");
- if (result.success) {
+ if (result.success && result.message) {
toast.showMessage(result.message);
} else {
toast.showError(t("sync_2.handshake_failed", { message: result.message }));