[251019] fix: Resolve warnings-1

🕐 커밋 시간: 2025. 10. 19. 23:37:25

📊 변경 통계:
  • 총 파일: 18개
  • 추가: +347줄
  • 삭제: -449줄

📝 수정된 파일:
  ~ com.twin.app.shoptime/src/components/VideoPlayer/MediaPlayer.jsx
  ~ com.twin.app.shoptime/src/utils/fp.js
  ~ com.twin.app.shoptime/src/utils/helperMethods.js
  ~ com.twin.app.shoptime/src/utils/lodashFpEx.js
  ~ com.twin.app.shoptime/src/utils/spotlight-utils.js
  ~ com.twin.app.shoptime/src/views/DetailPanel/DetailPanel.jsx
  ~ com.twin.app.shoptime/src/views/DetailPanel/DetailPanelSkeleton/DetailPanelSkeleton.jsx
  ~ com.twin.app.shoptime/src/views/PlayerPanel/PlayerItemCard/PlayerItemCard.jsx
  ~ com.twin.app.shoptime/src/views/PlayerPanel/PlayerOverlay/PlayerOverlayContents.jsx
  ~ com.twin.app.shoptime/src/views/SearchPanel/SearchPanel.new.jsx
  ~ com.twin.app.shoptime/src/views/SearchPanel/SearchResults.new.jsx
  ~ com.twin.app.shoptime/src/views/SearchPanel/SearchResultsNew/ItemCard.jsx
  ~ com.twin.app.shoptime/src/views/SearchPanel/SearchResultsNew/ShowCard.jsx
  ~ com.twin.app.shoptime/src/views/SearchPanel/TInput/TInput.jsx
  ~ com.twin.app.shoptime/src/views/SearchPanel/VoiceInputOverlay/VoiceInputOverlay.jsx
  ~ com.twin.app.shoptime/src/views/SearchPanel/VoiceInputOverlay/modes/VoicePromptScreen.jsx
  ~ com.twin.app.shoptime/src/views/SearchPanel/VoiceInputOverlay/modes/VoiceResponse.jsx
  ~ com.twin.app.shoptime/src/views/UserReview/ShowUserReviews.jsx

🔧 함수 변경 내용:
  📊 Function-level changes summary across 18 files:
    • Functions added: 8
    • Functions modified: 14
    • Functions deleted: 17
  📋 By language:
    • javascript: 18 files, 39 function changes

🔧 주요 변경 내용:
  • UI 컴포넌트 아키텍처 개선
  • 공통 유틸리티 함수 최적화

Performance: 코드 최적화로 성능 개선 기대
This commit is contained in:
2025-10-19 23:37:30 +09:00
parent edbc7628c7
commit f70e2b1a21
18 changed files with 746 additions and 866 deletions

View File

@@ -1,20 +1,18 @@
import { Job } from "@enact/core/util";
import Enact_$L from "@enact/i18n/$L";
import { Job } from '@enact/core/util';
import stringReSourceDe from "../../resources/de/strings.json";
import stringReSourceEn from "../../resources/en/strings.json";
import stringReSourceGb from "../../resources/gb/strings.json";
import stringReSourceRu from "../../resources/ru/strings.json";
import { getRicCode } from "../api/apiConfig";
import { ERROR_MESSAGES_GROUPS, SECRET_KEY } from "./Config";
import stringReSourceDe from '../../resources/de/strings.json';
import stringReSourceEn from '../../resources/en/strings.json';
import stringReSourceGb from '../../resources/gb/strings.json';
import stringReSourceRu from '../../resources/ru/strings.json';
import { ERROR_MESSAGES_GROUPS, SECRET_KEY } from './Config';
let _boundingRectCache = {};
const BOUNDING_RECT_IGNORE_TIME = 10;
const generateUUID = () => {
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
var r = (Math.random() * 16) | 0,
v = c === "x" ? r : (r & 0x3) | 0x8;
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const r = (Math.random() * 16) | 0;
const v = c === 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
};
@@ -37,10 +35,7 @@ export const getBoundingClientRect = (node) => {
const uuid = node.dataset.uuid;
if (_boundingRectCache[uuid]) {
if (
Date.now() - _boundingRectCache[uuid].called <
BOUNDING_RECT_IGNORE_TIME
) {
if (Date.now() - _boundingRectCache[uuid].called < BOUNDING_RECT_IGNORE_TIME) {
return _boundingRectCache[uuid].boundingRect;
}
}
@@ -63,42 +58,38 @@ const stringReSource = {
};
export const $L = (str) => {
let languageSetting = "system";
let resourceKey = "";
let languageSetting = 'system';
let resourceKey = '';
if (typeof window === "object" && window.store) {
if (typeof window === 'object' && window.store) {
languageSetting = window.store.getState().localSettings.languageSetting;
if (languageSetting === "system") {
if (languageSetting === 'system') {
resourceKey = window.store.getState().common.httpHeader?.cntry_cd;
} else {
resourceKey = languageSetting;
}
}
const resource = stringReSource[resourceKey];
if (typeof str === "object") {
if (typeof str === 'object') {
if (resource && resource[str.key]) {
return resource[str.key].replace(/{br}/g, "{br}");
return resource[str.key].replace(/{br}/g, '{br}');
} else {
return str.value;
}
} else if (resource && resource[str]) {
return resource[str].replace(/{br}/g, "{br}");
return resource[str].replace(/{br}/g, '{br}');
}
return str && str.replace(/{br}/g, "{br}");
return str && str.replace(/{br}/g, '{br}');
};
export const createQueryString = (object) => {
const parts = [];
for (const key of Object.getOwnPropertyNames(object)) {
if (
object[key] !== null &&
object[key] !== undefined &&
object[key] !== ""
) {
if (object[key] !== null && object[key] !== undefined && object[key] !== '') {
parts.push(`${key}=${encodeURIComponent(object[key])}`);
}
}
return parts.join("&");
return parts.join('&');
};
export const wait = (time) => {
@@ -110,14 +101,14 @@ export const wait = (time) => {
};
export const scaleW = (value) => {
if (typeof window === "object") {
if (typeof window === 'object') {
return value * (window.innerWidth / 1920);
}
return value;
};
export const scaleH = (value) => {
if (typeof window === "object") {
if (typeof window === 'object') {
return value * (window.innerHeight / 1080);
}
return value;
@@ -150,14 +141,10 @@ let localLaunchParams = {
export const getLaunchParams = () => {
let params = {};
if (
typeof window === "object" &&
window.PalmSystem &&
window.PalmSystem.launchParams
) {
if (typeof window === 'object' && window.PalmSystem && window.PalmSystem.launchParams) {
try {
params = JSON.parse(window.PalmSystem.launchParams);
if (params["x-webos-app-container-launch"] === true) {
if (params['x-webos-app-container-launch'] === true) {
params = params.details;
}
} catch (e) {
@@ -170,28 +157,24 @@ export const getLaunchParams = () => {
};
export const clearLaunchParams = () => {
console.log("common.clearLaunchParams");
if (
typeof window === "object" &&
window.PalmSystem &&
window.PalmSystem.launchParams
) {
window.PalmSystem.launchParams = "";
console.log('common.clearLaunchParams');
if (typeof window === 'object' && window.PalmSystem && window.PalmSystem.launchParams) {
window.PalmSystem.launchParams = '';
} else {
localLaunchParams = {};
}
};
export const readLocalStorage = (key, defaultValue) => {
const value = typeof window === "object" && window.localStorage.getItem(key);
const value = typeof window === 'object' && window.localStorage.getItem(key);
if (!value && defaultValue !== undefined) {
return defaultValue;
}
return value === "undefined" ? null : JSON.parse(value);
return value === 'undefined' ? null : JSON.parse(value);
};
export const writeLocalStorage = (key, value) => {
if (typeof window === "object") {
if (typeof window === 'object') {
window.localStorage.setItem(key, JSON.stringify(value));
}
};
@@ -199,34 +182,29 @@ export const writeLocalStorage = (key, value) => {
export const convertToTimeFormat = (timeString, isIncludeDate = false) => {
const date = new Date(timeString);
let options = { hour: "numeric", minute: "2-digit", hour12: true };
let pattern = " ";
let options = { hour: 'numeric', minute: '2-digit', hour12: true };
let pattern = ' ';
if (isIncludeDate) {
options = {
...options,
month: "2-digit",
day: "2-digit",
year: "numeric",
hour: "2-digit",
month: '2-digit',
day: '2-digit',
year: 'numeric',
hour: '2-digit',
};
pattern = ",";
pattern = ',';
}
return new Intl.DateTimeFormat("en-US", options)
.format(date)
.replace(pattern, "");
return new Intl.DateTimeFormat('en-US', options).format(date).replace(pattern, '');
};
export const getTranslate3dValueByDirection = (
element,
isHorizontal = true
) => {
export const getTranslate3dValueByDirection = (element, isHorizontal = true) => {
try {
const transformStyle = window.getComputedStyle(element).transform;
if (!transformStyle || transformStyle === "none") {
throw new Error("transfrom style not found");
if (!transformStyle || transformStyle === 'none') {
throw new Error('transfrom style not found');
}
const transformMatrix = transformStyle.match(/^matrix\((.+)\)$/);
@@ -234,7 +212,7 @@ export const getTranslate3dValueByDirection = (
let index, value;
if (transformMatrix) {
const matrixValues = transformMatrix[1].split(", ");
const matrixValues = transformMatrix[1].split(', ');
index = isHorizontal ? 4 : 5;
@@ -248,28 +226,22 @@ export const getTranslate3dValueByDirection = (
};
export const formatGMTString = (date) => {
let string = date.toISOString().replace(/T/, " ").replace(/\..+/, "");
let string = date.toISOString().replace(/T/, ' ').replace(/\..+/, '');
return string;
};
export const getSpottableDescendants = (containerId) => {
let container = document.querySelector(
`[data-spotlight-id="${containerId}"]`
);
let container = document.querySelector(`[data-spotlight-id="${containerId}"]`);
if (container) {
return container.querySelectorAll('[class*="spottable"]');
}
return [];
};
export const isElementInContainer = (
element,
container,
fullyVisible = true
) => {
export const isElementInContainer = (element, container, fullyVisible = true) => {
// 요소와 컨테이너의 사각형 정보 가져오기
if (typeof window === "object") {
if (typeof window === 'object') {
const elementRect = getBoundingClientRect(element);
const containerRect = container
? getBoundingClientRect(container)
@@ -334,9 +306,7 @@ export const getRectDiff = (element1, element2) => {
};
export const getFormattingCardNo = (cardNumber) => {
return `${"*".repeat(12)}${cardNumber.slice(-4)}`
.replace(/(.{4})/g, "$1-")
.slice(0, -1);
return `${'*'.repeat(12)}${cardNumber.slice(-4)}`.replace(/(.{4})/g, '$1-').slice(0, -1);
};
export const getQRCodeUrl = ({
@@ -345,41 +315,41 @@ export const getQRCodeUrl = ({
index,
patnrId,
prdtId,
dirPurcSelYn = "Y",
dirPurcSelYn = 'Y',
prdtData,
qrType,
liveFlag = "Y",
liveFlag = 'Y',
entryMenu,
nowMenu,
}) => {
if (!serverHOST) {
console.error("getQRCodeUrl: Not Supported, Host is missing");
console.error('getQRCodeUrl: Not Supported, Host is missing');
return {};
}
let sdpURL = serverHOST.split(".")[0];
let countryCode = "";
let sdpURL = serverHOST.split('.')[0];
let countryCode = '';
if (sdpURL.indexOf("-") > 0) {
countryCode = sdpURL.split("-")[1];
if (sdpURL.indexOf('-') > 0) {
countryCode = sdpURL.split('-')[1];
} else {
countryCode = sdpURL;
}
sdpURL = sdpURL.toLowerCase();
if (serverType !== "system") {
if (serverType !== 'system') {
sdpURL = serverType;
}
let baseUrl = "";
let baseUrl = '';
if (sdpURL.indexOf("qt2") >= 0) {
baseUrl = "https://qt2-m.shoptime.lgappstv.com/";
} else if (sdpURL.indexOf("qt") >= 0) {
baseUrl = "https://qt-m.shoptime.lgappstv.com/";
if (sdpURL.indexOf('qt2') >= 0) {
baseUrl = 'https://qt2-m.shoptime.lgappstv.com/';
} else if (sdpURL.indexOf('qt') >= 0) {
baseUrl = 'https://qt-m.shoptime.lgappstv.com/';
} else {
baseUrl = "https://m.shoptime.lgappstv.com/";
baseUrl = 'https://m.shoptime.lgappstv.com/';
}
const prdtDataStr = JSON.stringify(prdtData);
const prdtDataBase64 = btoa(prdtDataStr);
@@ -402,25 +372,25 @@ export const getQRCodeUrl = ({
// ex: JANUARY 01, 2024
export const getFormattingDate = (dateString) => {
const date = new Date(dateString.replace(" ", "T"));
const date = new Date(dateString.replace(' ', 'T'));
const monthNames = [
$L("JANUARY"),
$L("FEBRUARY"),
$L("MARCH"),
$L("APRIL"),
$L("MAY"),
$L("JUNE"),
$L("JULY"),
$L("AUGUST"),
$L("SEPTEMBER"),
$L("OCTOBER"),
$L("NOVEMBER"),
$L("DECEMBER"),
$L('JANUARY'),
$L('FEBRUARY'),
$L('MARCH'),
$L('APRIL'),
$L('MAY'),
$L('JUNE'),
$L('JULY'),
$L('AUGUST'),
$L('SEPTEMBER'),
$L('OCTOBER'),
$L('NOVEMBER'),
$L('DECEMBER'),
];
const month = monthNames[date.getMonth()];
const day = date.getDate().toString().padStart(2, "0");
const day = date.getDate().toString().padStart(2, '0');
const year = date.getFullYear();
return `${month} ${day}, ${year}`;
@@ -437,14 +407,14 @@ export const removeSpecificTags = (html) => {
let sanitizedHtml = html;
tagPatterns.forEach((pattern) => {
sanitizedHtml = sanitizedHtml.replace(pattern, "");
sanitizedHtml = sanitizedHtml.replace(pattern, '');
});
return sanitizedHtml;
};
export const encryptPhoneNumber = (phoneNumber) => {
if (typeof window === "object") {
if (typeof window === 'object') {
return window.CryptoJS.AES.encrypt(phoneNumber, SECRET_KEY).toString();
}
@@ -452,7 +422,7 @@ export const encryptPhoneNumber = (phoneNumber) => {
};
export const decryptPhoneNumber = (encryptedPhoneNumber) => {
if (typeof window === "object") {
if (typeof window === 'object') {
const bytes = window.CryptoJS.AES.decrypt(encryptedPhoneNumber, SECRET_KEY);
return bytes.toString(window.CryptoJS.enc.Utf8);
}
@@ -461,63 +431,54 @@ export const decryptPhoneNumber = (encryptedPhoneNumber) => {
};
export const formatLocalDateTime = (date) => {
const isDate = (obj) =>
Object.prototype.toString.call(obj) === "[object Date]";
const isDate = (obj) => Object.prototype.toString.call(obj) === '[object Date]';
if (typeof window === "object" && isDate(date)) {
if (typeof window === 'object' && isDate(date)) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
const seconds = String(date.getSeconds()).padStart(2, "0");
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
return "";
return '';
};
export const parseLocalizedNumber = (numberString, countryCode) => {
// 유럽식: 1.499,00 -> 1499.00
if (countryCode === "DE") {
return parseFloat(numberString.replace(/\./g, "").replace(",", "."));
if (countryCode === 'DE') {
return parseFloat(numberString.replace(/\./g, '').replace(',', '.'));
}
// 미국식: 1,499.00 -> 1499.00
if (countryCode === "US" || countryCode === "GB") {
return parseFloat(numberString.replace(/[^0-9.-]+/g, ""));
if (countryCode === 'US' || countryCode === 'GB') {
return parseFloat(numberString.replace(/[^0-9.-]+/g, ''));
}
// 러시아식: 1 499,00 -> 1499.00
if (countryCode === "RU") {
return parseFloat(numberString.replace(/\s/g, "").replace(",", "."));
if (countryCode === 'RU') {
return parseFloat(numberString.replace(/\s/g, '').replace(',', '.'));
}
return parseFloat(numberString);
};
export const formatCurrencyValue = (
value,
currSign,
currSignLoc,
isDiscount = false
) => {
if (value === "-" || value === 0) return "-";
export const formatCurrencyValue = (value, currSign, currSignLoc, isDiscount = false) => {
if (value === '-' || value === 0) return '-';
const numValue = parseFloat(value);
if (isNaN(numValue)) return "-";
if (isNaN(numValue)) return '-';
const sign = isDiscount && numValue > 0 ? "- " : "";
const formattedValue = parseFloat(numValue.toFixed(2)).toLocaleString(
"en-US",
{
minimumFractionDigits: 2,
maximumFractionDigits: 2,
}
);
const sign = isDiscount && numValue > 0 ? '- ' : '';
const formattedValue = parseFloat(numValue.toFixed(2)).toLocaleString('en-US', {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
});
if (!currSign || !currSignLoc) return `${sign}${formattedValue}`;
return currSignLoc === "L"
return currSignLoc === 'L'
? `${sign}${currSign} ${formattedValue}`
: `${sign}${formattedValue} ${currSign}`;
};
@@ -536,44 +497,31 @@ export const getTimeDifferenceByMilliseconds = (
return false;
}
const convertedStartTime = new Date(startTimeString.replace(/ /, "T") + "Z");
const convertedEndTime = new Date(endTimeString.replace(/ /, "T") + "Z");
const convertedStartTime = new Date(startTimeString.replace(/ /, 'T') + 'Z');
const convertedEndTime = new Date(endTimeString.replace(/ /, 'T') + 'Z');
const timeDifference = convertedEndTime - convertedStartTime;
return timeDifference > threshold;
};
export const getErrorMessage = (
errorCode,
retMsg,
retDetailCode,
returnBindStrings
) => {
const group = ERROR_MESSAGES_GROUPS.find((group) =>
group.codes.includes(Number(errorCode))
);
export const getErrorMessage = (errorCode, retMsg, retDetailCode, returnBindStrings) => {
const foundGroup = ERROR_MESSAGES_GROUPS.find((group) => group.codes.includes(Number(errorCode)));
const errorPrefix = errorCode
? retDetailCode
? `[${errorCode}-${retDetailCode}] `
: `[${errorCode}] `
: "";
: '';
if (group) {
if (
errorCode === 1120 &&
returnBindStrings &&
typeof returnBindStrings === "object"
) {
return `${errorPrefix} ${group.message} (ID: ${returnBindStrings.join(
", "
)})`;
if (foundGroup) {
if (errorCode === 1120 && returnBindStrings && typeof returnBindStrings === 'object') {
return `${errorPrefix} ${foundGroup.message} (ID: ${returnBindStrings.join(', ')})`;
}
return errorPrefix + group.message;
return errorPrefix + foundGroup.message;
} else if (retMsg) {
return errorPrefix + retMsg;
} else {
return errorPrefix + "An unknown error occurred. Please try again later.";
return errorPrefix + 'An unknown error occurred. Please try again later.';
}
};