[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:
@@ -45,7 +45,7 @@ import { pushPanel } from '../actions/panelActions';
|
||||
import { enqueuePanelHistory } from '../actions/panelHistoryActions';
|
||||
import NotSupportedVersion from '../components/NotSupportedVersion/NotSupportedVersion';
|
||||
import ToastContainer from '../components/TToast/ToastContainer';
|
||||
import GlobalPopup from '../components/GlobalPopup/GlobalPopup';
|
||||
|
||||
import usePrevious from '../hooks/usePrevious';
|
||||
import { lunaTest } from '../lunaSend/lunaTest';
|
||||
import { store } from '../store/store';
|
||||
@@ -407,28 +407,7 @@ Spotlight.silentlyFocus = function (...args) {
|
||||
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]
|
||||
// DOM 이벤트 리스너로 대체
|
||||
@@ -448,7 +427,7 @@ const resolveSpotlightIdFromEvent = (event) => {
|
||||
// });
|
||||
// }
|
||||
|
||||
function AppBase(props) {
|
||||
function AppBase(_props) {
|
||||
const dispatch = useDispatch();
|
||||
const httpHeader = useSelector((state) => state.common.httpHeader);
|
||||
const httpHeaderRef = useRef(httpHeader);
|
||||
@@ -650,7 +629,7 @@ function AppBase(props) {
|
||||
clearLaunchParams();
|
||||
}
|
||||
},
|
||||
[dispatch]
|
||||
[/* dispatch */]
|
||||
);
|
||||
|
||||
const handleRelaunchEvent = useCallback(() => {
|
||||
@@ -704,7 +683,7 @@ function AppBase(props) {
|
||||
if (typeof window === 'object' && window.PalmSystem) {
|
||||
window.PalmSystem.activate();
|
||||
}
|
||||
}, [initService, introTermsAgreeRef, dispatch]);
|
||||
}, [initService, introTermsAgreeRef /*, dispatch */]);
|
||||
|
||||
const visibilityChanged = useCallback(() => {
|
||||
// console.log('document is hidden', document.hidden);
|
||||
@@ -748,7 +727,7 @@ function AppBase(props) {
|
||||
}, [dispatch]);
|
||||
|
||||
useEffect(() => {
|
||||
const keyDownEvent = (event) => {
|
||||
const keyDownEvent = (_event) => {
|
||||
dispatch(changeAppStatus({ cursorVisible: false }));
|
||||
Spotlight.setPointerMode(false);
|
||||
};
|
||||
@@ -757,7 +736,7 @@ function AppBase(props) {
|
||||
let lastMoveTime = 0;
|
||||
const THROTTLE_MS = 100;
|
||||
|
||||
const mouseMoveEvent = (event) => {
|
||||
const mouseMoveEvent = (_event) => {
|
||||
const now = Date.now();
|
||||
if (now - lastMoveTime < THROTTLE_MS) {
|
||||
// throttle 기간 내에는 hideCursor만 재시작
|
||||
@@ -810,9 +789,7 @@ function AppBase(props) {
|
||||
let userDataChanged = false;
|
||||
if (JSON.stringify(loginUserDataRef.current) !== JSON.stringify(loginUserData)) {
|
||||
userDataChanged = true;
|
||||
}
|
||||
if (!httpHeader || !deviceId) {
|
||||
} else if (userDataChanged || httpHeaderRef.current === null) {
|
||||
} else if (userDataChanged || httpHeaderRef.current === null) {
|
||||
//계정정보 변경시 또는 초기 로딩시
|
||||
if (!httpHeader) {
|
||||
dispatch(
|
||||
|
||||
@@ -7,9 +7,7 @@ import Spotlight from '@enact/spotlight';
|
||||
import appinfo from '../../webos-meta/appinfo.json';
|
||||
import appinfo35 from '../../webos-meta/appinfo35.json';
|
||||
import appinfo79 from '../../webos-meta/appinfo79.json';
|
||||
import { handleBypassLink } from '../App/bypassLinkHandler';
|
||||
import * as lunaSend from '../lunaSend';
|
||||
import { initialLocalSettings } from '../reducers/localSettingsReducer';
|
||||
import * as Config from '../utils/Config';
|
||||
import * as HelperMethods from '../utils/helperMethods';
|
||||
import { types } from './actionTypes';
|
||||
@@ -17,7 +15,7 @@ import { createDebugHelpers } from '../utils/debug';
|
||||
|
||||
// 디버그 헬퍼 설정
|
||||
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 appinfo35 from "../../webos-meta/appinfo35.json";
|
||||
@@ -94,7 +92,7 @@ export const toggleOptionalTermsConfirm = (selected) => ({
|
||||
payload: selected,
|
||||
});
|
||||
|
||||
export const setExitApp = () => (dispatch, getState) => {
|
||||
export const setExitApp = () => (dispatch) => {
|
||||
dispatch({ type: types.SET_EXIT_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 ');
|
||||
lunaSend.getSystemSettings(
|
||||
{ category: 'caption', keys: ['captionEnable'] },
|
||||
{
|
||||
onSuccess: (res) => {},
|
||||
onFailure: (err) => {},
|
||||
onSuccess: () => {},
|
||||
onFailure: () => {},
|
||||
onComplete: (res) => {
|
||||
dlog('getSystemSettings onComplete', res);
|
||||
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 ');
|
||||
const { serverType, ricCodeSetting, languageSetting } = getState().localSettings;
|
||||
lunaSend.getHttpHeaderForServiceRequest({
|
||||
@@ -267,10 +265,9 @@ export const getHttpHeaderForServiceRequest = (onComplete) => (dispatch, getStat
|
||||
const mbrNo = res['X-User-Number'];
|
||||
|
||||
lunaSend.getLoginUserData(parameters, {
|
||||
onSuccess: (res) => {
|
||||
const userId = res.id ?? '';
|
||||
const userNumber = res.lastSignInUserNo;
|
||||
const profileNick = res.profileNick || userId.split('@')[0];
|
||||
onSuccess: (loginRes) => {
|
||||
const userId = loginRes.id ?? '';
|
||||
const profileNick = loginRes.profileNick || userId.split('@')[0];
|
||||
dispatch(
|
||||
getLoginUserData({
|
||||
userId,
|
||||
@@ -288,7 +285,7 @@ export const getHttpHeaderForServiceRequest = (onComplete) => (dispatch, getStat
|
||||
});
|
||||
};
|
||||
|
||||
export const getDeviceId = (onComplete) => (dispatch, getState) => {
|
||||
export const getDeviceId = (onComplete) => (dispatch) => {
|
||||
lunaSend.getDeviceId(
|
||||
{ idType: ['LGUDID'] },
|
||||
{
|
||||
@@ -466,7 +463,7 @@ export const setFocus = (spotlightId) => ({
|
||||
payload: spotlightId,
|
||||
});
|
||||
|
||||
export const focusElement = (spotlightId) => (dispatch, getState) => {
|
||||
export const focusElement = (spotlightId) => (dispatch) => {
|
||||
dispatch(setFocus(spotlightId));
|
||||
|
||||
if (typeof window === 'object') {
|
||||
@@ -488,7 +485,7 @@ export const cancelFocusElement = () => () => {
|
||||
let broadcastTimer = null;
|
||||
export const sendBroadCast =
|
||||
({ type, moreInfo }) =>
|
||||
(dispatch, getState) => {
|
||||
(dispatch) => {
|
||||
clearTimeout(broadcastTimer);
|
||||
dispatch(changeBroadcastEvent({ type, moreInfo }));
|
||||
broadcastTimer = setTimeout(() => {
|
||||
@@ -545,7 +542,7 @@ export const addReservation = (data) => (dispatch) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteReservationCallback = (scheduleIdList) => (dispatch) => {
|
||||
export const deleteReservationCallback = (scheduleIdList) => () => {
|
||||
lunaSend.deleteReservationCallback(scheduleIdList, {
|
||||
onSuccess: (res) => {
|
||||
// dispatch(alertToast("success" + JSON.stringify(res)));
|
||||
@@ -636,8 +633,8 @@ export const showError =
|
||||
export const deleteOldDb8Datas = () => (dispatch) => {
|
||||
for (let i = 1; i < 10; i++) {
|
||||
lunaSend.deleteOldDb8(i, {
|
||||
onSuccess: (res) => {},
|
||||
onFailure: (err) => {},
|
||||
onSuccess: () => {},
|
||||
onFailure: () => {},
|
||||
});
|
||||
}
|
||||
dispatch(changeLocalSettings({ oldDb8Deleted: true }));
|
||||
@@ -683,7 +680,7 @@ let updateNetworkStateJob = new Job((dispatch, connected) => {
|
||||
dispatch(changeAppStatus({ isInternetConnected: connected }));
|
||||
});
|
||||
|
||||
export const getConnectionStatus = () => (dispatch, getState) => {
|
||||
export const getConnectionStatus = () => (dispatch) => {
|
||||
lunaSend.getConnectionStatus({
|
||||
onSuccess: (res) => {
|
||||
dlog('lunasend getConnectionStatus', res);
|
||||
@@ -712,7 +709,7 @@ export const getConnectionStatus = () => (dispatch, getState) => {
|
||||
};
|
||||
|
||||
// macAddress
|
||||
export const getConnectionInfo = () => (dispatch, getState) => {
|
||||
export const getConnectionInfo = () => (dispatch) => {
|
||||
lunaSend.getConnectionInfo({
|
||||
onSuccess: (res) => {
|
||||
dlog('lunasend getConnectionStatus', res);
|
||||
@@ -734,7 +731,7 @@ export const getConnectionInfo = () => (dispatch, getState) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const disableNotification = () => (dispatch, getState) => {
|
||||
export const disableNotification = () => {
|
||||
lunaSend.disableNotification({
|
||||
onSuccess: (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({
|
||||
onSuccess: (res) => {
|
||||
dlog('lunasend enable notification success', res);
|
||||
|
||||
@@ -348,8 +348,14 @@ export const TAxiosAdvancedPromise = (
|
||||
clearTimeout(timeoutId);
|
||||
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})`);
|
||||
setTimeout(() => {
|
||||
attemptRequest();
|
||||
|
||||
@@ -1987,35 +1987,25 @@ export default function SearchPanel({ panelInfo, isOnTop, spotlightId }) {
|
||||
/**
|
||||
* LOG 용도,
|
||||
* 검색 시 로그를 보내는 용도의 이펙트
|
||||
* 우선 주석처리 (계속보내는부분에 대한 처리 필요)
|
||||
*/
|
||||
// useEffect(() => {
|
||||
// const result = Object.values(searchDatas).reduce((acc, curr) => {
|
||||
// return acc + curr.length;
|
||||
// }, 0);
|
||||
useEffect(() => {
|
||||
const result = Object.values(searchDatas).reduce((acc, curr) => {
|
||||
return acc + curr.length;
|
||||
}, 0);
|
||||
|
||||
// if (searchQuery) {
|
||||
// dispatch(
|
||||
// sendLogTotalRecommend({
|
||||
// query: searchQuery,
|
||||
// searchType: searchPerformed ? 'query' : 'keyword',
|
||||
// result: result,
|
||||
// contextName: LOG_CONTEXT_NAME.SEARCH,
|
||||
// messageId: LOG_MESSAGE_ID.SEARCH_ITEM,
|
||||
// })
|
||||
// );
|
||||
|
||||
// // 검색 완료 후 결과에 따른 Toast 표시
|
||||
// // if (searchPerformed && searchQuery.trim()) {
|
||||
// // if (result > 0) {
|
||||
// // dispatch(showSearchSuccessToast(searchQuery, result));
|
||||
// // } else {
|
||||
// // dispatch(showSearchErrorToast(searchQuery));
|
||||
// // }
|
||||
// // }
|
||||
// }
|
||||
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
// }, [searchDatas, searchPerformed, searchQuery]);
|
||||
if (searchQuery) {
|
||||
dispatch(
|
||||
sendLogTotalRecommend({
|
||||
query: searchQuery,
|
||||
searchType: searchPerformed ? 'query' : 'keyword',
|
||||
result: result,
|
||||
contextName: LOG_CONTEXT_NAME.SEARCH,
|
||||
messageId: LOG_MESSAGE_ID.SEARCH_ITEM,
|
||||
})
|
||||
);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [searchDatas, searchPerformed, searchQuery]);
|
||||
|
||||
/**
|
||||
* clean up 용도
|
||||
|
||||
Reference in New Issue
Block a user