Skip to content

Commit abdefd7

Browse files
committed
Fix empty mail on first load
1 parent 746595f commit abdefd7

File tree

6 files changed

+567
-513
lines changed

6 files changed

+567
-513
lines changed

components/actions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Button } from "@/components/ui/button";
44
import { CheckCircle, Edit, Shuffle } from "lucide-react";
55
import { Input } from "@/components/ui/input";
66
import SelectWrap from "@/components/select-wrap";
7-
import { domainList } from "@/lib/constant";
7+
import { DOMAIN_LIST } from "@/lib/constant";
88
import Mounted from "@/components/mounted";
99
import { useConfig } from "@/lib/store/config";
1010
import { Skeleton } from "@/components/ui/skeleton";
@@ -67,7 +67,7 @@ function Actions() {
6767
<SelectWrap
6868
value={domain}
6969
setValue={(domain) => setDomain(domain)}
70-
list={domainList}
70+
list={DOMAIN_LIST}
7171
disabled={!edited}
7272
/>
7373
</Mounted>

components/mail-refresh.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import React, { useEffect, useState } from "react";
33
import { Button } from "@/components/ui/button";
44
import { RefreshCw } from "lucide-react";
5-
import { refreshSeconds } from "@/lib/constant";
5+
import { REFRESH_SECONDS } from "@/lib/constant";
66
import { useEnvelope } from "@/lib/store/envelope";
77
import { useConfig } from "@/lib/store/config";
88
import { useToast } from "@/components/ui/use-toast";
@@ -24,8 +24,8 @@ function MailRefresh() {
2424
useEffect(() => {
2525
const timerId = setTimeout(
2626
async () => {
27-
if (seconds >= refreshSeconds - 1 || !timer) {
28-
await onRefresh();
27+
if (seconds >= REFRESH_SECONDS - 1 || !timer) {
28+
emitter.emit(mittKey.REFRESH);
2929
return;
3030
}
3131
setSeconds(seconds + 1);
@@ -70,7 +70,7 @@ function MailRefresh() {
7070
)}
7171
<span className="self-end pb-0.5 text-sm text-muted-foreground">
7272
将在
73-
<span className="font-medium">{refreshSeconds - seconds}s</span>
73+
<span className="font-medium">{REFRESH_SECONDS - seconds}s</span>
7474
后自动刷新
7575
</span>
7676
</>

lib/constant.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
export const domainList = ["@sliu.eu.org"];
1+
export const DOMAIN_LIST = ["@sliu.eu.org"];
22

3-
export const refreshSeconds = process.env.NODE_ENV === "development" ? 100 : 10;
3+
export const REFRESH_SECONDS =
4+
process.env.NODE_ENV === "development" ? 100 : 10;
45

56
export const VERSION = "1.0.1";

lib/store/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { create } from "zustand";
22
import { persist } from "zustand/middleware";
33
import { randomMail } from "@/lib/utils";
4-
import { domainList } from "@/lib/constant";
4+
import { DOMAIN_LIST } from "@/lib/constant";
55

66
interface Config {
77
mail: string;
@@ -14,7 +14,7 @@ export const useConfig = create<Config>()(
1414
persist(
1515
(set) => ({
1616
mail: randomMail(),
17-
domain: domainList[0],
17+
domain: DOMAIN_LIST[0],
1818
update(mail: string, domain: string) {
1919
set({ mail, domain });
2020
},

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,31 @@
1515
"@radix-ui/react-toast": "^1.1.5",
1616
"class-variance-authority": "^0.7.0",
1717
"clsx": "^2.1.0",
18-
"imapflow": "^1.0.152",
19-
"lucide-react": "^0.331.0",
20-
"mailparser": "^3.6.7",
18+
"imapflow": "^1.0.156",
19+
"lucide-react": "^0.358.0",
20+
"mailparser": "^3.6.9",
2121
"mitt": "^3.0.1",
22-
"next": "^14.1.0",
22+
"next": "^14.1.3",
2323
"react": "^18.2.0",
2424
"react-dom": "^18.2.0",
2525
"tailwind-merge": "^2.2.1",
26-
"zustand": "^4.5.1"
26+
"zustand": "^4.5.2"
2727
},
2828
"devDependencies": {
2929
"@types/imapflow": "^1.0.18",
3030
"@types/mailparser": "^3.4.4",
31-
"@types/node": "^20.11.19",
32-
"@types/react": "^18.2.56",
33-
"@types/react-dom": "^18.2.19",
34-
"autoprefixer": "^10.4.17",
35-
"eslint": "^8.56.0",
36-
"eslint-config-next": "^14.1.0",
31+
"@types/node": "^20.11.28",
32+
"@types/react": "^18.2.66",
33+
"@types/react-dom": "^18.2.22",
34+
"autoprefixer": "^10.4.18",
35+
"eslint": "^8.57.0",
36+
"eslint-config-next": "^14.1.3",
3737
"eslint-config-prettier": "^9.1.0",
3838
"postcss": "^8.4.35",
3939
"prettier": "^3.2.5",
40-
"prettier-plugin-tailwindcss": "^0.5.11",
40+
"prettier-plugin-tailwindcss": "^0.5.12",
4141
"tailwindcss": "^3.4.1",
4242
"tailwindcss-animate": "^1.0.7",
43-
"typescript": "^5.3.3"
43+
"typescript": "^5.4.2"
4444
}
4545
}

0 commit comments

Comments
 (0)