From 4fda68b024b05bcad88d8c6ef64f8b629908f13a Mon Sep 17 00:00:00 2001 From: bangnokia Date: Wed, 15 Jun 2022 17:43:34 +0700 Subject: [PATCH] revert defualt tab to html --- src/components/EmailBodyTabs.tsx | 2 +- src/store.tsx | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/components/EmailBodyTabs.tsx b/src/components/EmailBodyTabs.tsx index db08b10..bec72c4 100644 --- a/src/components/EmailBodyTabs.tsx +++ b/src/components/EmailBodyTabs.tsx @@ -4,7 +4,7 @@ import BrokenLinksChecker from "./BrokenLinksChecker"; export default function EmailBodyTabs({ email }: { email: Email }) { const tabs = ["html", "html source", "text", "raw", 'links checker']; - const [activeTab, setActiveTab] = useState("links checker"); + const [activeTab, setActiveTab] = useState("html"); return ( <> diff --git a/src/store.tsx b/src/store.tsx index 98a804a..4782468 100644 --- a/src/store.tsx +++ b/src/store.tsx @@ -32,13 +32,7 @@ const useStore = create((set) => ({ currentEmailId: state.currentEmailId === email.id ? undefined : state.currentEmailId, })), setEmailLinks: (email: Email, links: EmailLink[]) => set((state) => { - const index = state.emails.findIndex((e) => e.id === email.id); - if (index === -1) { - return state; - } - // replace the email in the state - const newEmails = [...state.emails]; - newEmails[index] = { ...email, links }; + const newEmails = state.emails.map(e => e.id === email.id ? { ...email, links } : e); return { emails: newEmails }; }) }));