Skip to content

refactor: 인스타그램 딥링크 매직 넘버를 상수로 추출#326

Merged
AndyH0ng merged 2 commits into
developfrom
copilot/extract-deep-link-timeout-constant
Mar 2, 2026
Merged

refactor: 인스타그램 딥링크 매직 넘버를 상수로 추출#326
AndyH0ng merged 2 commits into
developfrom
copilot/extract-deep-link-timeout-constant

Conversation

Copilot AI commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Magic numbers 1800 and 1200 in the Instagram deep link fallback logic were undocumented, making the timing intent unclear.

Changes

  • src/utils/snsShare.ts
    • Extracted 1800INSTAGRAM_DEEPLINK_TIMEOUT_MS: threshold to detect whether the deep link was handled by the app
    • Extracted 1200INSTAGRAM_DEEPLINK_FALLBACK_DELAY_MS: delay before checking if the deep link failed
    • Grouped both constants with related Instagram constants at the top of the internal utilities section
const INSTAGRAM_DEEPLINK_TIMEOUT_MS = 1800;
const INSTAGRAM_DEEPLINK_FALLBACK_DELAY_MS = 1200;

// ...

window.setTimeout(() => {
  if (Date.now() - start < INSTAGRAM_DEEPLINK_TIMEOUT_MS) {
    openNewTab(INSTAGRAM_WEB_URL);
  }
}, INSTAGRAM_DEEPLINK_FALLBACK_DELAY_MS);
Original prompt
Please apply the following diffs and create a pull request.
Once the PR is ready, give it a title based on the messages of the fixes being applied.

[{"message":"The magic number 1800 milliseconds should be extracted as a named constant (e.g., `DEEPLINK_TIMEOUT_MS`) to clarify its purpose in detecting deep link failures.","fixFiles":[{"filePath":"src/utils/snsShare.ts","diff":"diff --git a/src/utils/snsShare.ts b/src/utils/snsShare.ts\n--- a/src/utils/snsShare.ts\n+++ b/src/utils/snsShare.ts\n@@ -49,6 +49,7 @@\n \n const DEFAULT_SHARE_TEXT = '내 발표를 확인하고 피드백을 남겨주세요!';\n const INSTAGRAM_WEB_URL = 'https://www.instagram.com/';\n+const INSTAGRAM_DEEPLINK_TIMEOUT_MS = 1800;\n \n function encode(value: string) {\n   return encodeURIComponent(value);\n@@ -104,7 +105,7 @@\n \n   // 딥링크 실패(앱 미설치/미지원) 시 웹 인스타로 fallback\n   window.setTimeout(() => {\n-    if (Date.now() - start < 1800) {\n+    if (Date.now() - start < INSTAGRAM_DEEPLINK_TIMEOUT_MS) {\n       openNewTab(INSTAGRAM_WEB_URL);\n     }\n   }, 1200);\n"}]},{"message":"The magic number 1200 milliseconds should be extracted as a named constant (e.g., `DEEPLINK_CHECK_DELAY_MS`) to explain why this specific delay is used for fallback timing.","fixFiles":[{"filePath":"src/utils/snsShare.ts","diff":"diff --git a/src/utils/snsShare.ts b/src/utils/snsShare.ts\n--- a/src/utils/snsShare.ts\n+++ b/src/utils/snsShare.ts\n@@ -97,6 +97,8 @@\n   URL.revokeObjectURL(objectUrl);\n }\n \n+const INSTAGRAM_DEEPLINK_FALLBACK_DELAY_MS = 1200;\n+\n function openInstagramStoryDeepLink(qrCodeUrl: string) {\n   const deepLink = `instagram-stories://share?backgroundImage=${encode(qrCodeUrl)}`;\n   const start = Date.now();\n@@ -107,7 +109,7 @@\n     if (Date.now() - start < 1800) {\n       openNewTab(INSTAGRAM_WEB_URL);\n     }\n-  }, 1200);\n+  }, INSTAGRAM_DEEPLINK_FALLBACK_DELAY_MS);\n }\n \n /** Kakao SDK 스크립트를 동적으로 로드 */\n"}]}]

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: AndyH0ng <60703412+AndyH0ng@users.noreply.github.com>
Copilot AI changed the title [WIP] Extract magic number as named constant for deep link timeout refactor: extract Instagram deep link magic numbers as named constants Mar 2, 2026
@AndyH0ng AndyH0ng marked this pull request as ready for review March 2, 2026 04:33
@AndyH0ng AndyH0ng merged commit e185430 into develop Mar 2, 2026
8 checks passed
@AndyH0ng AndyH0ng deleted the copilot/extract-deep-link-timeout-constant branch March 2, 2026 04:33
@AndyH0ng AndyH0ng changed the title refactor: extract Instagram deep link magic numbers as named constants refactor: 인스타그램 딥링크 매직 넘버를 상수로 추출 Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants