fix: update os check modal ineligible date format

This commit is contained in:
Zack Spear
2024-02-29 14:15:12 -08:00
committed by Zack Spear
parent cefda7c42b
commit 8cf4aff622
2 changed files with 31 additions and 3 deletions

View File

@@ -49,9 +49,20 @@ const {
checkForUpdatesLoading,
} = storeToRefs(updateOsStore);
const {
outputDateTimeFormatted: formattedRegExp,
} = useDateTimeHelper(dateTimeFormat.value, props.t, true, regExp.value);
/**
* regExp may not have a value until we get a response from the refreshServerState action
* So we need to watch for this value to be able to format it based on the user's date time preferences.
*/
const formattedRegExp = ref<any>();
const setFormattedRegExp = () => { // ran in watch on regExp and onBeforeMount
if (!regExp.value) { return; }
const { outputDateTimeFormatted } = useDateTimeHelper(dateTimeFormat.value, props.t, true, regExp.value);
formattedRegExp.value = outputDateTimeFormatted.value;
};
watch(regExp, (_newV) => {
setFormattedRegExp();
});
const ignoreThisRelease = ref(false);
// if we had a release ignored and now we don't set ignoreThisRelease to false
@@ -208,6 +219,7 @@ onBeforeMount(() => {
if (availableReleaseDate.value) {
setUserFormattedReleaseDate();
}
setFormattedRegExp();
});
const modalWidth = computed(() => {

View File

@@ -33,6 +33,22 @@ const timeFormatOptions: TimeFormatOption[] = [
];
/**
* the provided ref may not have a value until we get a response from the refreshServerState action
* So we need to watch for this value to be able to format it based on the user's date time preferences.
* @example below is how to use this composable
* const formattedRegExp = ref<any>();
* const setFormattedRegExp = () => { // ran in watch on regExp and onBeforeMount
* if (!regExp.value) { return; }
* const { outputDateTimeFormatted } = useDateTimeHelper(dateTimeFormat.value, props.t, true, regExp.value);
* formattedRegExp.value = outputDateTimeFormatted.value;
* };
* watch(regExp, (_newV) => {
* setFormattedRegExp();
* });
* onBeforeMount(() => {
* setFormattedRegExp();
* });
*
* @param format provided by Unraid server's state.php and set in the server store
* @param t translations
* @param hideMinutesSeconds true will hide minutes and seconds from the output