Skip to content

Commit

Permalink
feat: some optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
Innei committed Sep 7, 2024
1 parent 66174a0 commit 5f61579
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 3 deletions.
1 change: 1 addition & 0 deletions icons/mgc/time_cute_re copy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const TimeStamp = (props: { time: string }) => {
nextFrame(() => AudioPlayer.seek(timeStringToSeconds(props.time) || 0))
}}
>
<i className="i-mgc-time-cute-re translate-y-0.5 mr-1" />
{props.time}
</span>
)
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/modules/settings/control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const SettingActionItem = ({
className={cn("relative mb-3 mt-4 flex items-center justify-between gap-4")}
>
<div className="text-sm font-medium">{label}</div>
<Button buttonClassName="text-xs absolute right-0" onClick={action}>
<Button buttonClassName="text-xs absolute right-0" variant="outline" onClick={action}>
{buttonText}
</Button>
</div>
Expand Down
30 changes: 28 additions & 2 deletions src/renderer/src/modules/settings/tabs/general.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
setUISetting,
useUISettingSelector,
} from "@renderer/atoms/settings/ui"
import { Button } from "@renderer/components/ui/button"
import { useModalStack } from "@renderer/components/ui/modal"
import {
Select,
SelectContent,
Expand Down Expand Up @@ -40,6 +42,7 @@ export const SettingGeneral = () => {
setGeneralSetting("appLaunchOnStartup", checked)
}, [])

const { present } = useModalStack()
return (
<>
<SettingsTitle />
Expand Down Expand Up @@ -128,8 +131,31 @@ export const SettingGeneral = () => {
{
label: "Rebuild Database",
action: async () => {
await clearLocalPersistStoreData()
window.location.reload()
present({
title: "Rebuild Database",
clickOutsideToDismiss: true,
content: () => (
<div className="text-sm">
<p>
Rebuilding the database will clear all your local data.
</p>
<p>Are you sure you want to continue?</p>

<div className="mt-4 flex justify-end">
<Button
className="text-red-500 px-3"
variant="ghost"
onClick={async () => {
await clearLocalPersistStoreData()
window.location.reload()
}}
>
Yes
</Button>
</div>
</div>
),
})
},
description:
"If you are experiencing rendering issues, rebuilding the database may solve them.",
Expand Down
5 changes: 5 additions & 0 deletions src/renderer/src/store/image/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ export const saveImageDimensionsToDb = async (
url: string,
dimensions: StoreImageType,
) => await set(url, dimensions, db)

export const clearImageDimensionsDb = async () => {
const store = await db("readwrite", (store) => store.clear())
return store
}
2 changes: 2 additions & 0 deletions src/renderer/src/store/utils/clear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { browserDB } from "@renderer/database"

import { entryActions } from "../entry"
import { feedActions } from "../feed"
import { clearImageDimensionsDb } from "../image/db"
import { subscriptionActions } from "../subscription"
import { feedUnreadActions } from "../unread"

Expand All @@ -16,5 +17,6 @@ export const clearLocalPersistStoreData = async () => {

clearUISettings()

await clearImageDimensionsDb()
await browserDB.delete().catch(() => null)
}

0 comments on commit 5f61579

Please sign in to comment.