diff --git a/src/background/listeners/iframeCommandHandler.ts b/src/background/listeners/iframeCommandHandler.ts index 5f66ac5..173231d 100644 --- a/src/background/listeners/iframeCommandHandler.ts +++ b/src/background/listeners/iframeCommandHandler.ts @@ -18,22 +18,23 @@ export async function handleIframeToggle(): Promise { iframeId, ) as HTMLIFrameElement; - // 현재 iframeInvisible 상태 확인 + // 현재 iframeInvisible과 iframeHiddenByAltA 상태 확인 chrome.storage.local.get( ["iframeInvisible", "iframeHiddenByAltA"], function (result) { const isInvisible = result.iframeInvisible ?? false; + const hiddenByAltA = + result.iframeHiddenByAltA ?? false; if (existingIframe) { - // iframe이 있으면 제거하고 상태를 true로 설정 existingIframe.remove(); chrome.storage.local.set({ iframeInvisible: true, - iframeHiddenByAltA: false, + iframeHiddenByAltA: true, }); - } else { - // iframe이 없으면 생성하고 상태를 false로 설정 + } else if (!hiddenByAltA) { + // hiddenByAltA가 false일 때만 iframe 생성 const iframe = document.createElement("iframe"); iframe.id = iframeId; diff --git a/src/background/listeners/modalCommandHandler.ts b/src/background/listeners/modalCommandHandler.ts index 37e6b48..2ae8ff7 100644 --- a/src/background/listeners/modalCommandHandler.ts +++ b/src/background/listeners/modalCommandHandler.ts @@ -3,6 +3,7 @@ export async function handleModalToggle(): Promise { active: true, currentWindow: true, }); + if (tabs[0]?.id) { await chrome.scripting.executeScript({ target: { tabId: tabs[0].id }, @@ -12,20 +13,23 @@ export async function handleModalToggle(): Promise { iframeId, ) as HTMLIFrameElement; - if (!iframe) { - // iframeInvisible 상태 확인 - chrome.storage.local.get( - [ - "iframeInvisible", - "iframeHiddenByAltA", - "iframeHiddenByAltV", - ], - (result) => { - const isInvisible = result.iframeInvisible ?? false; - const hiddenByAltA = - result.iframeHiddenByAltA ?? false; + // 항상 iframeHiddenByAltA 먼저 검사 + chrome.storage.local.get( + [ + "iframeInvisible", + "iframeHiddenByAltA", + "iframeHiddenByAltV", + ], + (result) => { + const isInvisible = result.iframeInvisible ?? false; + const hiddenByAltA = result.iframeHiddenByAltA ?? false; + const hiddenByAltV = result.iframeHiddenByAltV ?? false; + + // ✅ Alt+A로 숨긴 상태면 아무 동작도 하지 않음 + if (hiddenByAltA) return; - // ALT+V로 숨긴 경우에만 iframe 생성하고 모달 띄우기 + if (!iframe) { + // Alt+V로 숨겨진 상태일 때만 iframe 생성 if (isInvisible) { iframe = document.createElement("iframe"); iframe.id = iframeId; @@ -52,9 +56,9 @@ export async function handleModalToggle(): Promise { const handleMessage = function ( event: MessageEvent, ) { - if (event.source !== iframe.contentWindow) { + if (event.source !== iframe.contentWindow) return; - } + if (event.data.type === "RESIZE_IFRAME") { if (event.data.isOpen) { iframe.style.width = "100%"; @@ -74,11 +78,13 @@ export async function handleModalToggle(): Promise { handleMessage, ); document.body.appendChild(iframe); + chrome.storage.local.set({ iframeInvisible: false, iframeHiddenByAltA: false, iframeHiddenByAltV: true, }); + iframe.onload = function () { if (iframe.contentWindow) { iframe.contentWindow.postMessage( @@ -88,20 +94,13 @@ export async function handleModalToggle(): Promise { } }; } - }, - ); - } else { - if (iframe.contentWindow) { - iframe.contentWindow.postMessage( - { type: "TOGGLE_MODAL" }, - "*", - ); - - chrome.storage.local.get( - ["iframeHiddenByAltV"], - (result) => { - const hiddenByAltV = - result.iframeHiddenByAltV ?? false; + } else { + // iframe이 이미 존재할 때 + if (iframe.contentWindow) { + iframe.contentWindow.postMessage( + { type: "TOGGLE_MODAL" }, + "*", + ); if (hiddenByAltV) { iframe.remove(); @@ -111,10 +110,10 @@ export async function handleModalToggle(): Promise { iframeHiddenByAltV: false, }); } - }, - ); - } - } + } + } + }, + ); }, }); } diff --git a/src/components/productComponents/ReviewSummaryComponent.tsx b/src/components/productComponents/ReviewSummaryComponent.tsx index 941fdca..cf7a23a 100644 --- a/src/components/productComponents/ReviewSummaryComponent.tsx +++ b/src/components/productComponents/ReviewSummaryComponent.tsx @@ -28,7 +28,7 @@ export const ReviewSummaryComponent = ({ isDarkMode ? "text-grayscale-100" : "text-grayscale-900" } text-center py-10`} > - 불러오는중입니다... + 리뷰를 불러오는 중입니다. 잠시만 기다려주세요. ); } diff --git a/src/components/sidebar/component.tsx b/src/components/sidebar/component.tsx index 9c3baae..5894e60 100644 --- a/src/components/sidebar/component.tsx +++ b/src/components/sidebar/component.tsx @@ -154,6 +154,7 @@ export function Sidebar({ keywords: [], } } + isLoading={!reviewSummary} /> ); default: