Skip to content

refactor(useNoticeModal): 만료 시점 관리를 위한 expireDate 추가#393

Merged
nijuy merged 1 commit into
developfrom
refactor/notice-modal-once
Apr 6, 2026
Merged

refactor(useNoticeModal): 만료 시점 관리를 위한 expireDate 추가#393
nijuy merged 1 commit into
developfrom
refactor/notice-modal-once

Conversation

@nijuy
Copy link
Copy Markdown
Collaborator

@nijuy nijuy commented Apr 6, 2026

💻 개요

  • 리팩토링

📋 변경 및 추가 사항

  • 기존 useNoticeModal은 공지가 없는 상태를 표현하는 코드가 없었어요

    • 공지가 없을 때는 CURRENT_ID를 빈 문자열로 두는지 null로 바꾸는지 판단할 수가 X
  • 공지 내릴 때마다 코드 수정하려면 귀찮으니까. 만료 시점을 추가했습니다

    • 기존 CURRENT_ID를 포함하는 객체를 만들었습니다

      const NOTICE_CONFIG = {
        id: 'notice_2025-07-10_bomb', // 공지 id
        expireDate: '2025-07-17T23:59:59+09:00', // 만료 시점
      } as const;
    • useNoticeModal에서 만료 시점이 지난 공지는 노출하지 않게 했습니다

        export const useNoticeModal = () => {
          const isNoticeExpired = () => { // 추가된 함수
            return new Date() > new Date(NOTICE_CONFIG.expireDate);
          };
        
          const openNoticeModal = () => {
            if (isNoticeExpired()) return; // 요기서 호출됨
          };
        
          return { openNoticeModal };
        };
  • 원래 뜨던 폭탄 공지는 2025-07-17로 만료일을 설정해서 이제 안 뜨게 됐습니다

    2026-04-06.5.20.03.mov

💬 To. 리뷰어

@nijuy nijuy self-assigned this Apr 6, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the notice modal logic by introducing a NOTICE_CONFIG object and an expiration check. The review feedback suggests optimizing performance by parsing the expiration date string into a Date object once at the module level to avoid redundant calculations within the hook.

Comment thread src/pages/games/SnackGame/game/hook/useNoticeModal.tsx
Comment thread src/pages/games/SnackGame/game/hook/useNoticeModal.tsx
@nijuy nijuy merged commit ae0a430 into develop Apr 6, 2026
1 check passed
@nijuy nijuy deleted the refactor/notice-modal-once branch April 6, 2026 08:26
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.

1 participant