mirror of https://github.com/jetkvm/kvm.git
fix: update custom version update logic
This commit is contained in:
parent
4411c45cd5
commit
0eff994878
|
|
@ -37,9 +37,11 @@ func (s *State) getUpdateURL(params UpdateParams) (string, error, bool) {
|
||||||
|
|
||||||
// set the custom versions if they are specified
|
// set the custom versions if they are specified
|
||||||
for component, constraint := range params.Components {
|
for component, constraint := range params.Components {
|
||||||
if constraint != "" {
|
if constraint == "" {
|
||||||
query.Set(component+"Version", constraint)
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query.Set(component+"Version", constraint)
|
||||||
isCustomVersion = true
|
isCustomVersion = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ export default function SettingsAdvancedRoute() {
|
||||||
const [systemVersion, setSystemVersion] = useState<string>("");
|
const [systemVersion, setSystemVersion] = useState<string>("");
|
||||||
const [resetConfig, setResetConfig] = useState(false);
|
const [resetConfig, setResetConfig] = useState(false);
|
||||||
const [versionChangeAcknowledged, setVersionChangeAcknowledged] = useState(false);
|
const [versionChangeAcknowledged, setVersionChangeAcknowledged] = useState(false);
|
||||||
const [versionUpdateLoading, setVersionUpdateLoading] = useState(false);
|
const [customVersionUpdateLoading, setCustomVersionUpdateLoading] = useState(false);
|
||||||
const settings = useSettingsStore();
|
const settings = useSettingsStore();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -192,19 +192,19 @@ export default function SettingsAdvancedRoute() {
|
||||||
}),
|
}),
|
||||||
{ duration: 1000 * 15 } // 15 seconds
|
{ duration: 1000 * 15 } // 15 seconds
|
||||||
);
|
);
|
||||||
setVersionUpdateLoading(false);
|
setCustomVersionUpdateLoading(false);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleVersionUpdate = useCallback(async () => {
|
const handleCustomVersionUpdate = useCallback(async () => {
|
||||||
const components: UpdateComponents = {};
|
const components: UpdateComponents = {};
|
||||||
if (["app", "both"].includes(updateTarget)) components.app = appVersion;
|
if (["app", "both"].includes(updateTarget) && appVersion) components.app = appVersion;
|
||||||
if (["system", "both"].includes(updateTarget)) components.system = systemVersion;
|
if (["system", "both"].includes(updateTarget) && systemVersion) components.system = systemVersion;
|
||||||
let versionInfo: SystemVersionInfo | undefined;
|
let versionInfo: SystemVersionInfo | undefined;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// we do not need to set it to false if check succeeds,
|
// we do not need to set it to false if check succeeds,
|
||||||
// because it will be redirected to the update page later
|
// because it will be redirected to the update page later
|
||||||
setVersionUpdateLoading(true);
|
setCustomVersionUpdateLoading(true);
|
||||||
versionInfo = await checkUpdateComponents({
|
versionInfo = await checkUpdateComponents({
|
||||||
components,
|
components,
|
||||||
}, devChannel);
|
}, devChannel);
|
||||||
|
|
@ -238,7 +238,7 @@ export default function SettingsAdvancedRoute() {
|
||||||
}, [
|
}, [
|
||||||
updateTarget, appVersion, systemVersion, devChannel,
|
updateTarget, appVersion, systemVersion, devChannel,
|
||||||
navigateTo, resetConfig, handleVersionUpdateError,
|
navigateTo, resetConfig, handleVersionUpdateError,
|
||||||
setVersionUpdateLoading
|
setCustomVersionUpdateLoading
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -404,10 +404,10 @@ export default function SettingsAdvancedRoute() {
|
||||||
(updateTarget === "system" && !systemVersion) ||
|
(updateTarget === "system" && !systemVersion) ||
|
||||||
(updateTarget === "both" && (!appVersion || !systemVersion)) ||
|
(updateTarget === "both" && (!appVersion || !systemVersion)) ||
|
||||||
!versionChangeAcknowledged ||
|
!versionChangeAcknowledged ||
|
||||||
versionUpdateLoading
|
customVersionUpdateLoading
|
||||||
}
|
}
|
||||||
loading={versionUpdateLoading}
|
loading={customVersionUpdateLoading}
|
||||||
onClick={handleVersionUpdate}
|
onClick={handleCustomVersionUpdate}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</NestedSettingsGroup>
|
</NestedSettingsGroup>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue