diff --git a/src/renderer/src/modules/settings/control.tsx b/src/renderer/src/modules/settings/control.tsx
index 3a97d2bcb..53036b701 100644
--- a/src/renderer/src/modules/settings/control.tsx
+++ b/src/renderer/src/modules/settings/control.tsx
@@ -1,3 +1,4 @@
+import { StyledButton } from "@renderer/components/ui/button"
import { Checkbox } from "@renderer/components/ui/checkbox"
import { Label } from "@renderer/components/ui/label"
import { Switch } from "@renderer/components/ui/switch"
@@ -53,3 +54,18 @@ export const SettingDescription: Component = ({ children, className }) => (
{children}
)
+
+export const SettingActionItem = ({
+ label,
+ action,
+ buttonText,
+}: {
+ label: string
+ action: () => void
+ buttonText: string
+}) => (
+
+
{label}
+
{buttonText}
+
+)
diff --git a/src/renderer/src/modules/settings/section.tsx b/src/renderer/src/modules/settings/section.tsx
index 042eadaa0..102637e0b 100644
--- a/src/renderer/src/modules/settings/section.tsx
+++ b/src/renderer/src/modules/settings/section.tsx
@@ -1,3 +1,4 @@
+/* eslint-disable @eslint-react/no-clone-element */
/* eslint-disable @eslint-react/no-children-to-array */
/* eslint-disable @eslint-react/no-children-map */
@@ -5,7 +6,11 @@ import type { FC, PropsWithChildren, ReactNode } from "react"
import { cloneElement } from "react"
import * as React from "react"
-import { SettingDescription, SettingSwitch } from "./control"
+import {
+ SettingActionItem,
+ SettingDescription,
+ SettingSwitch,
+} from "./control"
export const SettingSectionTitle: FC<{
title: string
@@ -30,11 +35,15 @@ export const SettingItemGroup: FC = ({ children }) => {
switch (prevType) {
case SettingSwitch: {
- // eslint-disable-next-line @eslint-react/no-clone-element
return cloneElement(child as React.ReactElement, {
className: "!-mt-2",
})
}
+ case SettingActionItem: {
+ return cloneElement(child as React.ReactElement, {
+ className: "!-mt-3",
+ })
+ }
default: {
return child
}
diff --git a/src/renderer/src/modules/settings/setting-builder.tsx b/src/renderer/src/modules/settings/setting-builder.tsx
index 647206277..e3536cd70 100644
--- a/src/renderer/src/modules/settings/setting-builder.tsx
+++ b/src/renderer/src/modules/settings/setting-builder.tsx
@@ -3,7 +3,11 @@ import type { FC, ReactNode } from "react"
import { isValidElement } from "react"
import * as React from "react"
-import { SettingDescription, SettingSwitch } from "./control"
+import {
+ SettingActionItem,
+ SettingDescription,
+ SettingSwitch,
+} from "./control"
import { SettingItemGroup, SettingSectionTitle } from "./section"
type SharedSettingItem = {
@@ -17,11 +21,17 @@ type SettingItem = {
onChange: (value: T[K]) => void
} & SharedSettingItem
-type SpecificSettingItem = {
+type SectionSettingItem = {
type: "title"
value?: string
} & SharedSettingItem
+type ActionSettingItem = {
+ label: string
+ action: () => void
+ description?: string
+ buttonText: string
+} & SharedSettingItem
type CustomSettingItem = ReactNode | FC
export const createSettingBuilder =
@@ -29,8 +39,9 @@ export const createSettingBuilder =
(props: {
settings: (
| SettingItem
- | SpecificSettingItem
+ | SectionSettingItem
| CustomSettingItem
+ | ActionSettingItem
| boolean
)[]
}) => {
@@ -41,8 +52,13 @@ export const createSettingBuilder =
.filter((i) => typeof i !== "boolean")
.map((setting, index) => {
if (isValidElement(setting)) return setting
- if (typeof setting === "function") { return React.createElement(setting, { key: index }) }
- const assertSetting = setting as SettingItem | SpecificSettingItem
+ if (typeof setting === "function") {
+ return React.createElement(setting, { key: index })
+ }
+ const assertSetting = setting as
+ | SettingItem
+ | SectionSettingItem
+ | ActionSettingItem
if (assertSetting.disabled) return null
@@ -60,25 +76,30 @@ export const createSettingBuilder =
}
let ControlElement: React.ReactNode
- switch (typeof settingObject[assertSetting.key]) {
- case "boolean": {
- ControlElement = (
-
- assertSetting.onChange(checked as T[keyof T])}
- label={assertSetting.label}
- />
- )
- break
- }
- case "string": {
- return null
- }
- default: {
- return null
+
+ if ("key" in assertSetting) {
+ switch (typeof settingObject[assertSetting.key]) {
+ case "boolean": {
+ ControlElement = (
+
+ assertSetting.onChange(checked as T[keyof T])}
+ label={assertSetting.label}
+ />
+ )
+ break
+ }
+ case "string": {
+ return null
+ }
+ default: {
+ return null
+ }
}
+ } else if ("action" in assertSetting) {
+ ControlElement =
}
return (
diff --git a/src/renderer/src/modules/settings/tabs/general.tsx b/src/renderer/src/modules/settings/tabs/general.tsx
index 31bcfbeff..304ac0898 100644
--- a/src/renderer/src/modules/settings/tabs/general.tsx
+++ b/src/renderer/src/modules/settings/tabs/general.tsx
@@ -4,6 +4,7 @@ import {
} from "@renderer/atoms/settings/general"
import { initPostHog } from "@renderer/initialize/posthog"
import { tipcClient } from "@renderer/lib/client"
+import { clearLocalPersistStoreData } from "@renderer/store/utils/clear"
import { useCallback, useEffect } from "react"
import { createSettingBuilder } from "../setting-builder"
@@ -100,6 +101,16 @@ export const SettingGeneral = () => {
}
},
},
+ {
+ label: "Rebuild Database",
+ action: () => {
+ clearLocalPersistStoreData()
+ window.location.reload()
+ },
+ description:
+ "If you are experiencing data rendering anomalies, try rebuilding the database, this action will reload the page.",
+ buttonText: "Rebuild",
+ },
]}
/>