QEVENT remider 예약시 webos 미호출 관련 수정
This commit is contained in:
@@ -10,6 +10,7 @@ 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";
|
||||
|
||||
export const changeAppStatus = (status) => ({
|
||||
@@ -504,10 +505,20 @@ export const requestLiveSubtitle =
|
||||
export const addReservation = (data) => (dispatch) => {
|
||||
lunaSend.addReservation(data, {
|
||||
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) => {
|
||||
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,13 +236,14 @@ export const setSubtitleEnableOver5 = (
|
||||
}
|
||||
};
|
||||
|
||||
// system Alert
|
||||
// system Alert with time validation
|
||||
export const addReservation = (data, { onSuccess, onFailure, onComplete }) => {
|
||||
if (typeof window === "object" && !window.PalmSystem) {
|
||||
console.log("LUNA SEND addReservation data", data);
|
||||
return;
|
||||
}
|
||||
|
||||
const createReservation = () => {
|
||||
return new LS2Request().send({
|
||||
service: "luna://com.webos.service.tvReservationAgent",
|
||||
method: "add",
|
||||
@@ -273,7 +274,6 @@ export const addReservation = (data, { onSuccess, onFailure, onComplete }) => {
|
||||
label: data.params.buttons[1].label,
|
||||
},
|
||||
],
|
||||
|
||||
autoTimeout: 30,
|
||||
},
|
||||
},
|
||||
@@ -283,9 +283,61 @@ export const addReservation = (data, { onSuccess, onFailure, onComplete }) => {
|
||||
},
|
||||
},
|
||||
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,
|
||||
});
|
||||
};
|
||||
|
||||
// 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 = (
|
||||
@@ -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.";
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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