feat: WIP UpdateOs page component

This commit is contained in:
Zack Spear
2023-09-19 18:49:13 -07:00
committed by Zack Spear
parent ab06ed75c3
commit 5c58a86d86
11 changed files with 170 additions and 22 deletions

View File

@@ -69,10 +69,8 @@ export const useUpdateOsStoreGeneric = (
}
// getters
const isOsVersionStable = computed(() => {
const hasPrerelease = prerelease(osVersion.value);
return !hasPrerelease;
});
const cachedReleasesTimestamp = computed(() => releases.value?.timestamp);
const isOsVersionStable = computed(() => !isVersionStable(osVersion.value));
const filteredStableReleases = computed(() => {
if (!osVersion.value) return undefined;
@@ -186,9 +184,11 @@ export const useUpdateOsStoreGeneric = (
/**
* If we're on stable and the user hasn't requested to include next releases in the check
* then remove next releases from the cached data
* then remove next releases from the data
*/
if (!payload.includeNext && isOsVersionStable.value && releases.value.response.next) {
console.debug('[checkForUpdate] checking for next releases', payload.includeNext, isOsVersionStable.value, releases.value.response.next)
if (!payload.includeNext || isOsVersionStable.value && releases.value.response.next) {
console.debug('[checkForUpdate] removing next releases from data')
delete releases.value.response.next;
}
@@ -238,11 +238,14 @@ export const useUpdateOsStoreGeneric = (
return releaseForReturn;
};
const isVersionStable = (version: SemVer | string): boolean => prerelease(version) === null;
return {
// state
available,
releases,
// getters
cachedReleasesTimestamp,
isOsVersionStable,
filteredStableReleases,
filteredNextReleases,
@@ -251,5 +254,6 @@ export const useUpdateOsStoreGeneric = (
checkForUpdate,
findReleaseByMd5,
requestReleases,
isVersionStable,
};
});

View File

@@ -22,8 +22,9 @@ import {
type UpdateOsActionStore,
} from '~/store/updateOs';
import { type InstallPluginPayload } from '~/composables/installPlugin';
import type { InstallPluginPayload } from '~/composables/installPlugin';
import type { ServerStateDataAction } from '~/types/server';
import type { UserProfileLink } from '~/types/userProfile';
/**
* @see https://stackoverflow.com/questions/73476371/using-pinia-with-vue-js-web-components
@@ -47,7 +48,7 @@ export const useUpdateOsActionsStore = defineStore('updateOsActions', () => {
const callbackUpdateRelease = ref<Release | null>(null);
// Actions
const initUpdateOsCallback = (includeNextReleases: boolean = false) => {
const initUpdateOsCallback = (includeNextReleases: boolean = false): UserProfileLink => {
return {
click: (includeNext: boolean = includeNextReleases) => {
callbackStore.send(