Skip to content

Commit

Permalink
fix: fix sync bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Peek-A-Booo committed Aug 19, 2023
1 parent 674fd81 commit bcb72c8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
29 changes: 18 additions & 11 deletions src/components/backup/modalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import { useFetchError } from "@/hooks/useFetchError";
import { useOpenAIStore } from "@/hooks/useOpenAI";
import { useChannelStore } from "@/hooks/useChannel";
import { useCharacterStore } from "@/hooks/useCharacter";
import { useUserInfoStore } from "@/hooks/useUserInfo";
import { syncStore } from "@/store/sync";
import { FREE_SYNC_SIZE } from "@/utils/constant";
import { FREE_SYNC_SIZE, PRO_SYNC_SIZE } from "@/utils/constant";

interface IProps {
onClose: () => void;
Expand All @@ -33,6 +34,7 @@ export default function ModalContent({ onClose }: IProps) {
state.list,
]);
const characterList = useCharacterStore((state) => state.list);
const license_type = useUserInfoStore((state) => state.license_type);
const syncSize = syncStore((state) => state.size);
const [loadingBackup, setLoadingBackup] = React.useState(false);
const [loadingRestore, setLoadingRestore] = React.useState(false);
Expand All @@ -45,9 +47,12 @@ export default function ModalContent({ onClose }: IProps) {
const importCharacterList = useCharacterStore((state) => state.importList);
const updateSyncSize = syncStore((state) => state.updateSize);

const isFree = license_type !== "premium" && license_type !== "team";
const totalSize = isFree ? FREE_SYNC_SIZE : PRO_SYNC_SIZE;

const syncUsage = React.useMemo(() => {
return (syncSize / FREE_SYNC_SIZE) * 100;
}, [syncSize]);
return (syncSize / totalSize) * 100;
}, [syncSize, isFree]);

const getSyncSize = async () => {
if (syncSize) return;
Expand Down Expand Up @@ -199,15 +204,17 @@ export default function ModalContent({ onClose }: IProps) {
<div>{tBackup("usage")}</div>
<div className="flex gap-1">
<div>
{syncSize} KB / {FREE_SYNC_SIZE} KB
{syncSize} KB / {totalSize} KB
</div>
<a
className="text-sky-400 dark:text-sky-500 hover:underline cursor-pointer"
href="https://docs.ltopx.com/features/cloud-synchronous"
target="_blank"
>
(Free)
</a>
{isFree && (
<a
className="text-sky-400 dark:text-sky-500 hover:underline cursor-pointer"
href="https://docs.ltopx.com/features/cloud-synchronous"
target="_blank"
>
(Free)
</a>
)}
</div>
</div>
<Progress
Expand Down
2 changes: 1 addition & 1 deletion src/utils/constant/price.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export const BASE_PRICE = 1000 * (1 / 0.002);

// Backup & Sync size
export const FREE_SYNC_SIZE = 50;
export const PRO_SYNC_SIZE = 50;
export const PRO_SYNC_SIZE = 1024;

1 comment on commit bcb72c8

@vercel
Copy link

@vercel vercel bot commented on bcb72c8 Aug 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.