플러팅 AI

플러팅 멘트 초기화 문제 해결

Solo.dev 2025. 5. 29. 23:22
플러팅 멘트 초기화 문제 요약

플러팅 멘트 초기화 문제 요약

문제 개요

  • 날짜: 2025년 5월 29일
  • 문제: 플러팅 멘트 횟수가 초기화되지 않음
  • 상태: 테스트 완료, 심사 제출 완료

원인 분석

  • 발견: adprovidersaveresultscreen에서 크레딧을 공유하고 있음
  • 문제점: adprovider가 크레딧을 먼저 사용하면 날짜가 동기화되어 플러팅 멘트 초기화가 이루어지지 않는 충돌 발생

해결 방법

  • adprovidersaveresultscreen의 크레딧을 분리
  • 각각 독립적으로 크레딧 관리하도록 수정
  • 날짜 동기화 로직 점검 및 충돌 방지

코드 예시

  • 아래는 크레딧 분리 후 adprovider의 수정된 로직 예시입니다.
class AdProvider {
    constructor() {
        this.credit = 0;
        this.lastResetDate = null;
    }

    initializeCredit() {
        const currentDate = new Date().toDateString();
        if (this.lastResetDate !== currentDate) {
            this.credit = 0; // 독립적으로 초기화
            this.lastResetDate = currentDate;
        }
    }

    useCredit(amount) {
        if (this.credit >= amount) {
            this.credit -= amount;
            return true;
        }
        return false;
    }
}

class SaveResultScreen {
    constructor() {
        this.credit = 0; // 별도의 크레딧 관리
        this.lastResetDate = null;
    }

    resetFloatingComment() {
        const currentDate = new Date().toDateString();
        if (this.lastResetDate !== currentDate) {
            this.credit = 0; // 플러팅 멘트 초기화
            this.lastResetDate = currentDate;
        }
    }
}

결과

  • 테스트: 수정된 로직으로 플러팅 멘트 초기화 정상 작동 확인
  • 심사: 최종 심사 제출 완료