From 7a499c3a19a0ca8bfdc68097affeb4da223fe94a Mon Sep 17 00:00:00 2001 From: choihooo Date: Thu, 29 May 2025 17:01:34 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20iframe=20=EB=B0=8F=20=EB=AA=A8?= =?UTF-8?q?=EB=8B=AC=20=EC=B2=98=EB=A6=AC=20=EB=A1=9C=EC=A7=81=20=EA=B0=9C?= =?UTF-8?q?=EC=84=A0=20=EB=B0=8F=20=EC=83=81=ED=83=9C=20=EA=B4=80=EB=A6=AC?= =?UTF-8?q?=20=EC=B5=9C=EC=A0=81=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listeners/iframeCommandHandler.ts | 11 ++-- .../listeners/modalCommandHandler.ts | 65 +++++++++---------- 2 files changed, 38 insertions(+), 38 deletions(-) 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, }); } - }, - ); - } - } + } + } + }, + ); }, }); } From cdef7660b5ed46a986b2d5ec1966bea2332340f7 Mon Sep 17 00:00:00 2001 From: choihooo Date: Thu, 29 May 2025 17:08:33 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=EB=A6=AC=EB=B7=B0=20=EB=A1=9C?= =?UTF-8?q?=EB=94=A9=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EA=B0=9C=EC=84=A0=20?= =?UTF-8?q?=EB=B0=8F=20=EC=82=AC=EC=9D=B4=EB=93=9C=EB=B0=94=20=EB=A1=9C?= =?UTF-8?q?=EB=94=A9=20=EC=83=81=ED=83=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/productComponents/ReviewSummaryComponent.tsx | 2 +- src/components/sidebar/component.tsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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: