[251126] fix: Log Migration - SearchPanel.new.v2.jsx

🕐 커밋 시간: 2025. 11. 26. 14:16:12

📊 변경 통계:
  • 총 파일: 4개
  • 추가: +51줄
  • 삭제: -81줄

📝 수정된 파일:
  ~ com.twin.app.shoptime/src/App/App.js
  ~ com.twin.app.shoptime/src/actions/commonActions.js
  ~ com.twin.app.shoptime/src/api/TAxios.js
  ~ com.twin.app.shoptime/src/views/SearchPanel/SearchPanel.new.v2.jsx

🔧 주요 변경 내용:
  • 핵심 비즈니스 로직 개선
  • API 서비스 레이어 개선
  • 소규모 기능 개선
  • 코드 정리 및 최적화

Performance: 코드 최적화로 성능 개선 기대
This commit is contained in:
2025-11-26 14:16:13 +09:00
parent 3add749c07
commit 4904c6fb58
4 changed files with 50 additions and 80 deletions

View File

@@ -45,7 +45,7 @@ import { pushPanel } from '../actions/panelActions';
import { enqueuePanelHistory } from '../actions/panelHistoryActions'; import { enqueuePanelHistory } from '../actions/panelHistoryActions';
import NotSupportedVersion from '../components/NotSupportedVersion/NotSupportedVersion'; import NotSupportedVersion from '../components/NotSupportedVersion/NotSupportedVersion';
import ToastContainer from '../components/TToast/ToastContainer'; import ToastContainer from '../components/TToast/ToastContainer';
import GlobalPopup from '../components/GlobalPopup/GlobalPopup';
import usePrevious from '../hooks/usePrevious'; import usePrevious from '../hooks/usePrevious';
import { lunaTest } from '../lunaSend/lunaTest'; import { lunaTest } from '../lunaSend/lunaTest';
import { store } from '../store/store'; import { store } from '../store/store';
@@ -407,28 +407,7 @@ Spotlight.silentlyFocus = function (...args) {
return ret; return ret;
}; };
const resolveSpotlightIdFromEvent = (event) => {
if (!event) return undefined;
const { detail, target } = event;
if (detail) {
if (detail.spotlightId) {
return detail.spotlightId;
}
if (detail.id) {
return detail.id;
}
if (detail.target && detail.target.dataset && detail.target.dataset.spotlightId) {
return detail.target.dataset.spotlightId;
}
}
if (target && target.dataset && target.dataset.spotlightId) {
return target.dataset.spotlightId;
}
return undefined;
};
// Spotlight Focus 추적 로그 [251115] // Spotlight Focus 추적 로그 [251115]
// DOM 이벤트 리스너로 대체 // DOM 이벤트 리스너로 대체
@@ -448,7 +427,7 @@ const resolveSpotlightIdFromEvent = (event) => {
// }); // });
// } // }
function AppBase(props) { function AppBase(_props) {
const dispatch = useDispatch(); const dispatch = useDispatch();
const httpHeader = useSelector((state) => state.common.httpHeader); const httpHeader = useSelector((state) => state.common.httpHeader);
const httpHeaderRef = useRef(httpHeader); const httpHeaderRef = useRef(httpHeader);
@@ -650,7 +629,7 @@ function AppBase(props) {
clearLaunchParams(); clearLaunchParams();
} }
}, },
[dispatch] [/* dispatch */]
); );
const handleRelaunchEvent = useCallback(() => { const handleRelaunchEvent = useCallback(() => {
@@ -704,7 +683,7 @@ function AppBase(props) {
if (typeof window === 'object' && window.PalmSystem) { if (typeof window === 'object' && window.PalmSystem) {
window.PalmSystem.activate(); window.PalmSystem.activate();
} }
}, [initService, introTermsAgreeRef, dispatch]); }, [initService, introTermsAgreeRef /*, dispatch */]);
const visibilityChanged = useCallback(() => { const visibilityChanged = useCallback(() => {
// console.log('document is hidden', document.hidden); // console.log('document is hidden', document.hidden);
@@ -748,7 +727,7 @@ function AppBase(props) {
}, [dispatch]); }, [dispatch]);
useEffect(() => { useEffect(() => {
const keyDownEvent = (event) => { const keyDownEvent = (_event) => {
dispatch(changeAppStatus({ cursorVisible: false })); dispatch(changeAppStatus({ cursorVisible: false }));
Spotlight.setPointerMode(false); Spotlight.setPointerMode(false);
}; };
@@ -757,7 +736,7 @@ function AppBase(props) {
let lastMoveTime = 0; let lastMoveTime = 0;
const THROTTLE_MS = 100; const THROTTLE_MS = 100;
const mouseMoveEvent = (event) => { const mouseMoveEvent = (_event) => {
const now = Date.now(); const now = Date.now();
if (now - lastMoveTime < THROTTLE_MS) { if (now - lastMoveTime < THROTTLE_MS) {
// throttle 기간 내에는 hideCursor만 재시작 // throttle 기간 내에는 hideCursor만 재시작
@@ -810,9 +789,7 @@ function AppBase(props) {
let userDataChanged = false; let userDataChanged = false;
if (JSON.stringify(loginUserDataRef.current) !== JSON.stringify(loginUserData)) { if (JSON.stringify(loginUserDataRef.current) !== JSON.stringify(loginUserData)) {
userDataChanged = true; userDataChanged = true;
} } else if (userDataChanged || httpHeaderRef.current === null) {
if (!httpHeader || !deviceId) {
} else if (userDataChanged || httpHeaderRef.current === null) {
//계정정보 변경시 또는 초기 로딩시 //계정정보 변경시 또는 초기 로딩시
if (!httpHeader) { if (!httpHeader) {
dispatch( dispatch(

View File

@@ -7,9 +7,7 @@ import Spotlight from '@enact/spotlight';
import appinfo from '../../webos-meta/appinfo.json'; import appinfo from '../../webos-meta/appinfo.json';
import appinfo35 from '../../webos-meta/appinfo35.json'; import appinfo35 from '../../webos-meta/appinfo35.json';
import appinfo79 from '../../webos-meta/appinfo79.json'; import appinfo79 from '../../webos-meta/appinfo79.json';
import { handleBypassLink } from '../App/bypassLinkHandler';
import * as lunaSend from '../lunaSend'; import * as lunaSend from '../lunaSend';
import { initialLocalSettings } from '../reducers/localSettingsReducer';
import * as Config from '../utils/Config'; import * as Config from '../utils/Config';
import * as HelperMethods from '../utils/helperMethods'; import * as HelperMethods from '../utils/helperMethods';
import { types } from './actionTypes'; import { types } from './actionTypes';
@@ -17,7 +15,7 @@ import { createDebugHelpers } from '../utils/debug';
// 디버그 헬퍼 설정 // 디버그 헬퍼 설정
const DEBUG_MODE = false; const DEBUG_MODE = false;
const { dlog, dwarn, derror } = createDebugHelpers(DEBUG_MODE); const { dlog, derror } = createDebugHelpers(DEBUG_MODE);
// ======= // =======
// import appinfo from "../../webos-meta/appinfo.json"; // import appinfo from "../../webos-meta/appinfo.json";
// import appinfo35 from "../../webos-meta/appinfo35.json"; // import appinfo35 from "../../webos-meta/appinfo35.json";
@@ -94,7 +92,7 @@ export const toggleOptionalTermsConfirm = (selected) => ({
payload: selected, payload: selected,
}); });
export const setExitApp = () => (dispatch, getState) => { export const setExitApp = () => (dispatch) => {
dispatch({ type: types.SET_EXIT_APP }); dispatch({ type: types.SET_EXIT_APP });
dlog('Exiting App...'); dlog('Exiting App...');
@@ -124,13 +122,13 @@ export const alertToast = (payload) => (dispatch, getState) => {
} }
}; };
export const getSystemSettings = () => (dispatch, getState) => { export const getSystemSettings = () => (dispatch) => {
dlog('getSystemSettings '); dlog('getSystemSettings ');
lunaSend.getSystemSettings( lunaSend.getSystemSettings(
{ category: 'caption', keys: ['captionEnable'] }, { category: 'caption', keys: ['captionEnable'] },
{ {
onSuccess: (res) => {}, onSuccess: () => {},
onFailure: (err) => {}, onFailure: () => {},
onComplete: (res) => { onComplete: (res) => {
dlog('getSystemSettings onComplete', res); dlog('getSystemSettings onComplete', res);
if (res && res.settings) { if (res && res.settings) {
@@ -148,7 +146,7 @@ export const getSystemSettings = () => (dispatch, getState) => {
); );
}; };
export const getHttpHeaderForServiceRequest = (onComplete) => (dispatch, getState) => { export const getHttpHeaderForServiceRequest = () => (dispatch, getState) => {
dlog('getHttpHeaderForServiceRequest '); dlog('getHttpHeaderForServiceRequest ');
const { serverType, ricCodeSetting, languageSetting } = getState().localSettings; const { serverType, ricCodeSetting, languageSetting } = getState().localSettings;
lunaSend.getHttpHeaderForServiceRequest({ lunaSend.getHttpHeaderForServiceRequest({
@@ -267,10 +265,9 @@ export const getHttpHeaderForServiceRequest = (onComplete) => (dispatch, getStat
const mbrNo = res['X-User-Number']; const mbrNo = res['X-User-Number'];
lunaSend.getLoginUserData(parameters, { lunaSend.getLoginUserData(parameters, {
onSuccess: (res) => { onSuccess: (loginRes) => {
const userId = res.id ?? ''; const userId = loginRes.id ?? '';
const userNumber = res.lastSignInUserNo; const profileNick = loginRes.profileNick || userId.split('@')[0];
const profileNick = res.profileNick || userId.split('@')[0];
dispatch( dispatch(
getLoginUserData({ getLoginUserData({
userId, userId,
@@ -288,7 +285,7 @@ export const getHttpHeaderForServiceRequest = (onComplete) => (dispatch, getStat
}); });
}; };
export const getDeviceId = (onComplete) => (dispatch, getState) => { export const getDeviceId = (onComplete) => (dispatch) => {
lunaSend.getDeviceId( lunaSend.getDeviceId(
{ idType: ['LGUDID'] }, { idType: ['LGUDID'] },
{ {
@@ -466,7 +463,7 @@ export const setFocus = (spotlightId) => ({
payload: spotlightId, payload: spotlightId,
}); });
export const focusElement = (spotlightId) => (dispatch, getState) => { export const focusElement = (spotlightId) => (dispatch) => {
dispatch(setFocus(spotlightId)); dispatch(setFocus(spotlightId));
if (typeof window === 'object') { if (typeof window === 'object') {
@@ -488,7 +485,7 @@ export const cancelFocusElement = () => () => {
let broadcastTimer = null; let broadcastTimer = null;
export const sendBroadCast = export const sendBroadCast =
({ type, moreInfo }) => ({ type, moreInfo }) =>
(dispatch, getState) => { (dispatch) => {
clearTimeout(broadcastTimer); clearTimeout(broadcastTimer);
dispatch(changeBroadcastEvent({ type, moreInfo })); dispatch(changeBroadcastEvent({ type, moreInfo }));
broadcastTimer = setTimeout(() => { broadcastTimer = setTimeout(() => {
@@ -545,7 +542,7 @@ export const addReservation = (data) => (dispatch) => {
}); });
}; };
export const deleteReservationCallback = (scheduleIdList) => (dispatch) => { export const deleteReservationCallback = (scheduleIdList) => () => {
lunaSend.deleteReservationCallback(scheduleIdList, { lunaSend.deleteReservationCallback(scheduleIdList, {
onSuccess: (res) => { onSuccess: (res) => {
// dispatch(alertToast("success" + JSON.stringify(res))); // dispatch(alertToast("success" + JSON.stringify(res)));
@@ -636,8 +633,8 @@ export const showError =
export const deleteOldDb8Datas = () => (dispatch) => { export const deleteOldDb8Datas = () => (dispatch) => {
for (let i = 1; i < 10; i++) { for (let i = 1; i < 10; i++) {
lunaSend.deleteOldDb8(i, { lunaSend.deleteOldDb8(i, {
onSuccess: (res) => {}, onSuccess: () => {},
onFailure: (err) => {}, onFailure: () => {},
}); });
} }
dispatch(changeLocalSettings({ oldDb8Deleted: true })); dispatch(changeLocalSettings({ oldDb8Deleted: true }));
@@ -683,7 +680,7 @@ let updateNetworkStateJob = new Job((dispatch, connected) => {
dispatch(changeAppStatus({ isInternetConnected: connected })); dispatch(changeAppStatus({ isInternetConnected: connected }));
}); });
export const getConnectionStatus = () => (dispatch, getState) => { export const getConnectionStatus = () => (dispatch) => {
lunaSend.getConnectionStatus({ lunaSend.getConnectionStatus({
onSuccess: (res) => { onSuccess: (res) => {
dlog('lunasend getConnectionStatus', res); dlog('lunasend getConnectionStatus', res);
@@ -712,7 +709,7 @@ export const getConnectionStatus = () => (dispatch, getState) => {
}; };
// macAddress // macAddress
export const getConnectionInfo = () => (dispatch, getState) => { export const getConnectionInfo = () => (dispatch) => {
lunaSend.getConnectionInfo({ lunaSend.getConnectionInfo({
onSuccess: (res) => { onSuccess: (res) => {
dlog('lunasend getConnectionStatus', res); dlog('lunasend getConnectionStatus', res);
@@ -734,7 +731,7 @@ export const getConnectionInfo = () => (dispatch, getState) => {
}); });
}; };
export const disableNotification = () => (dispatch, getState) => { export const disableNotification = () => {
lunaSend.disableNotification({ lunaSend.disableNotification({
onSuccess: (res) => { onSuccess: (res) => {
dlog('lunasend disable notification success', res); dlog('lunasend disable notification success', res);
@@ -748,7 +745,7 @@ export const disableNotification = () => (dispatch, getState) => {
}); });
}; };
export const enableNotification = () => (dispatch, getState) => { export const enableNotification = () => {
lunaSend.enableNotification({ lunaSend.enableNotification({
onSuccess: (res) => { onSuccess: (res) => {
dlog('lunasend enable notification success', res); dlog('lunasend enable notification success', res);

View File

@@ -348,8 +348,14 @@ export const TAxiosAdvancedPromise = (
clearTimeout(timeoutId); clearTimeout(timeoutId);
console.error(`TAxiosPromise error on attempt ${attempts} for ${baseUrl}:`, error); console.error(`TAxiosPromise error on attempt ${attempts} for ${baseUrl}:`, error);
// Check if the error is due to token expiration
// TAxios already handles token refresh and queueing for these codes (401, 402, 501)
// So we should NOT retry immediately in this loop, but let TAxios handle it.
const retCode = error?.data?.retCode;
const isTokenError = retCode === 401 || retCode === 402 || retCode === 501;
// 재시도 로직 // 재시도 로직
if (attempts < maxAttempts) { if (attempts < maxAttempts && !isTokenError) {
console.log(`Retrying in ${retryDelay}ms... (${attempts}/${maxAttempts})`); console.log(`Retrying in ${retryDelay}ms... (${attempts}/${maxAttempts})`);
setTimeout(() => { setTimeout(() => {
attemptRequest(); attemptRequest();

View File

@@ -1987,35 +1987,25 @@ export default function SearchPanel({ panelInfo, isOnTop, spotlightId }) {
/** /**
* LOG 용도, * LOG 용도,
* 검색 시 로그를 보내는 용도의 이펙트 * 검색 시 로그를 보내는 용도의 이펙트
* 우선 주석처리 (계속보내는부분에 대한 처리 필요)
*/ */
// useEffect(() => { useEffect(() => {
// const result = Object.values(searchDatas).reduce((acc, curr) => { const result = Object.values(searchDatas).reduce((acc, curr) => {
// return acc + curr.length; return acc + curr.length;
// }, 0); }, 0);
// if (searchQuery) { if (searchQuery) {
// dispatch( dispatch(
// sendLogTotalRecommend({ sendLogTotalRecommend({
// query: searchQuery, query: searchQuery,
// searchType: searchPerformed ? 'query' : 'keyword', searchType: searchPerformed ? 'query' : 'keyword',
// result: result, result: result,
// contextName: LOG_CONTEXT_NAME.SEARCH, contextName: LOG_CONTEXT_NAME.SEARCH,
// messageId: LOG_MESSAGE_ID.SEARCH_ITEM, messageId: LOG_MESSAGE_ID.SEARCH_ITEM,
// }) })
// ); );
}
// // 검색 완료 후 결과에 따른 Toast 표시 // eslint-disable-next-line react-hooks/exhaustive-deps
// // if (searchPerformed && searchQuery.trim()) { }, [searchDatas, searchPerformed, searchQuery]);
// // if (result > 0) {
// // dispatch(showSearchSuccessToast(searchQuery, result));
// // } else {
// // dispatch(showSearchErrorToast(searchQuery));
// // }
// // }
// }
// // eslint-disable-next-line react-hooks/exhaustive-deps
// }, [searchDatas, searchPerformed, searchQuery]);
/** /**
* clean up 용도 * clean up 용도