QEVENT remider 예약시 webos 미호출 관련 수정

This commit is contained in:
opacity@t-win.kr
2025-09-16 09:34:14 +09:00
parent 566b686056
commit 216e9a8b13
3 changed files with 192 additions and 42 deletions

View File

@@ -10,6 +10,7 @@ import { handleBypassLink } from "../App/bypassLinkHandler";
import * as lunaSend from "../lunaSend"; import * as lunaSend from "../lunaSend";
import { initialLocalSettings } from "../reducers/localSettingsReducer"; import { initialLocalSettings } from "../reducers/localSettingsReducer";
import * as Config from "../utils/Config"; import * as Config from "../utils/Config";
import * as HelperMethods from "../utils/helperMethods";
import { types } from "./actionTypes"; import { types } from "./actionTypes";
export const changeAppStatus = (status) => ({ export const changeAppStatus = (status) => ({
@@ -504,10 +505,20 @@ export const requestLiveSubtitle =
export const addReservation = (data) => (dispatch) => { export const addReservation = (data) => (dispatch) => {
lunaSend.addReservation(data, { lunaSend.addReservation(data, {
onSuccess: (res) => { onSuccess: (res) => {
console.log(res); console.log("addReservation success:", res);
// Optionally show success toast
if (res && res.returnValue) {
dispatch(alertToast("Reminder set successfully"));
}
}, },
onFailure: (err) => { onFailure: (err) => {
console.log(err); console.error("addReservation failed:", err);
// Use the helper function for better error handling
const errorMessage = HelperMethods.getReservationErrorMessage(err);
dispatch(alertToast(errorMessage));
},
onComplete: () => {
console.log("addReservation completed");
}, },
}); });
}; };

View File

@@ -236,13 +236,14 @@ export const setSubtitleEnableOver5 = (
} }
}; };
// system Alert // system Alert with time validation
export const addReservation = (data, { onSuccess, onFailure, onComplete }) => { export const addReservation = (data, { onSuccess, onFailure, onComplete }) => {
if (typeof window === "object" && !window.PalmSystem) { if (typeof window === "object" && !window.PalmSystem) {
console.log("LUNA SEND addReservation data", data); console.log("LUNA SEND addReservation data", data);
return; return;
} }
const createReservation = () => {
return new LS2Request().send({ return new LS2Request().send({
service: "luna://com.webos.service.tvReservationAgent", service: "luna://com.webos.service.tvReservationAgent",
method: "add", method: "add",
@@ -273,7 +274,6 @@ export const addReservation = (data, { onSuccess, onFailure, onComplete }) => {
label: data.params.buttons[1].label, label: data.params.buttons[1].label,
}, },
], ],
autoTimeout: 30, autoTimeout: 30,
}, },
}, },
@@ -283,9 +283,61 @@ export const addReservation = (data, { onSuccess, onFailure, onComplete }) => {
}, },
}, },
onSuccess, onSuccess,
onFailure, onFailure: (err) => {
console.log("LUNA SEND addReservation failed", err);
// Check if error is related to invalid current time
if (
err &&
err.errorText &&
err.errorText.includes("Invalid current time")
) {
console.log(
"Invalid current time error detected, will retry after time validation"
);
// Don't call onFailure immediately, let the retry logic handle it
return;
}
onFailure(err);
},
onComplete, onComplete,
}); });
};
// First, validate system time before creating reservation
const validateTimeAndCreateReservation = (retryCount = 0, maxRetries = 3) => {
console.log(`LUNA SEND validating system time, attempt ${retryCount + 1}`);
getSystemTime({
onSuccess: (timeRes) => {
console.log("LUNA SEND system time validation success", timeRes);
// Time is available, proceed with reservation
createReservation();
},
onFailure: (timeErr) => {
console.log("LUNA SEND system time validation failed", timeErr);
if (retryCount < maxRetries) {
// Retry with exponential backoff
const delay = Math.min(1000 * Math.pow(2, retryCount), 5000); // Max 5 seconds
console.log(`LUNA SEND retrying time validation in ${delay}ms`);
setTimeout(() => {
validateTimeAndCreateReservation(retryCount + 1, maxRetries);
}, delay);
} else {
console.log("LUNA SEND max retries exceeded for time validation");
// Still try to create reservation as fallback
createReservation();
}
},
onComplete: () => {
console.log("LUNA SEND system time validation complete");
},
});
};
// Start the validation and reservation process
validateTimeAndCreateReservation();
}; };
export const deleteReservationCallback = ( export const deleteReservationCallback = (
@@ -454,3 +506,48 @@ export const getConnectionInfo = ({ onSuccess, onFailure, onComplete }) => {
}); });
} }
}; };
// Check system time availability
export const getSystemTime = ({ onSuccess, onFailure, onComplete }) => {
if (typeof window === "object" && !window.PalmSystem) {
console.log("LUNA SEND getSystemTime - mock environment");
onSuccess({ returnValue: true, utc: Date.now() / 1000 });
return;
}
return new LS2Request().send({
service: "luna://com.webos.settingsservice",
method: "getSystemSettings",
subscribe: false,
parameters: {
category: "time",
keys: ["autoClock"],
},
onSuccess: (res) => {
console.log("LUNA SEND getSystemTime success", res);
if (res && res.returnValue) {
// If autoClock is available, try to get actual time
new LS2Request().send({
service: "luna://com.webos.service.systemservice",
method: "clock/getTime",
subscribe: false,
parameters: {},
onSuccess: (timeRes) => {
console.log("LUNA SEND clock/getTime success", timeRes);
onSuccess(timeRes);
},
onFailure: (timeErr) => {
console.log("LUNA SEND clock/getTime failed", timeErr);
// Fallback to settings response if getTime fails
onSuccess(res);
},
onComplete,
});
} else {
onFailure(res);
}
},
onFailure,
onComplete,
});
};

View File

@@ -577,3 +577,45 @@ export const getErrorMessage = (
return errorPrefix + "An unknown error occurred. Please try again later."; return errorPrefix + "An unknown error occurred. Please try again later.";
} }
}; };
/**
* Check if the reservation error is related to system time issues
* @param {Object} error - The error object from Luna service
* @returns {boolean} - True if error is time-related
*/
export const isTimeRelatedError = (error) => {
if (!error) return false;
const timeErrorPatterns = [
"Invalid current time",
"Fail to get Current Time",
"time not available",
"clock not set",
];
const errorText = error.errorText || error.message || "";
return timeErrorPatterns.some((pattern) =>
errorText.toLowerCase().includes(pattern.toLowerCase())
);
};
/**
* Get user-friendly error message for reservation failures
* @param {Object} error - The error object from Luna service
* @returns {string} - User-friendly error message
*/
export const getReservationErrorMessage = (error) => {
if (!error) return $L("Failed to set reminder. Please try again.");
if (isTimeRelatedError(error)) {
return $L(
"Unable to set reminder: System time not available. Please check your TV's time settings and try again."
);
}
if (error.errorText) {
return $L(`Failed to set reminder: ${error.errorText}`);
}
return $L("Failed to set reminder. Please try again.");
};