QEVENT remider 예약시 webos 미호출 관련 수정
This commit is contained in:
@@ -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");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -236,56 +236,108 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new LS2Request().send({
|
const createReservation = () => {
|
||||||
service: "luna://com.webos.service.tvReservationAgent",
|
return new LS2Request().send({
|
||||||
method: "add",
|
service: "luna://com.webos.service.tvReservationAgent",
|
||||||
parameters: {
|
method: "add",
|
||||||
scheduleType: "LGShopping",
|
parameters: {
|
||||||
startTime: {
|
scheduleType: "LGShopping",
|
||||||
year: data.startTime.year,
|
startTime: {
|
||||||
month: data.startTime.month,
|
year: data.startTime.year,
|
||||||
day: data.startTime.day,
|
month: data.startTime.month,
|
||||||
hour: data.startTime.hour,
|
day: data.startTime.day,
|
||||||
minute: data.startTime.minute,
|
hour: data.startTime.hour,
|
||||||
second: data.startTime.second,
|
minute: data.startTime.minute,
|
||||||
},
|
second: data.startTime.second,
|
||||||
callback: {
|
},
|
||||||
method: "luna://com.webos.notification/createAlert",
|
callback: {
|
||||||
params: {
|
method: "luna://com.webos.notification/createAlert",
|
||||||
message: data.params.message,
|
params: {
|
||||||
buttons: [
|
message: data.params.message,
|
||||||
{
|
buttons: [
|
||||||
label: data.params.buttons[0].label,
|
{
|
||||||
onclick: "luna://com.webos.applicationManager/launch",
|
label: data.params.buttons[0].label,
|
||||||
params: {
|
onclick: "luna://com.webos.applicationManager/launch",
|
||||||
id: window.PalmSystem.identifier ?? appinfo.id,
|
params: {
|
||||||
params: data.params.launch,
|
id: window.PalmSystem.identifier ?? appinfo.id,
|
||||||
|
params: data.params.launch,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
{
|
||||||
{
|
label: data.params.buttons[1].label,
|
||||||
label: data.params.buttons[1].label,
|
},
|
||||||
},
|
],
|
||||||
],
|
autoTimeout: 30,
|
||||||
|
},
|
||||||
autoTimeout: 30,
|
},
|
||||||
|
information: {
|
||||||
|
showId: data.params.showId,
|
||||||
|
chanId: data.params.chanId,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
information: {
|
onSuccess,
|
||||||
showId: data.params.showId,
|
onFailure: (err) => {
|
||||||
chanId: data.params.chanId,
|
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,
|
||||||
onSuccess,
|
});
|
||||||
onFailure,
|
};
|
||||||
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,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
@@ -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.");
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user