diff --git a/src/tribler/ui/src/pages/Settings/Versions.tsx b/src/tribler/ui/src/pages/Settings/Versions.tsx index 4a7968277b..4eec5f8d3b 100644 --- a/src/tribler/ui/src/pages/Settings/Versions.tsx +++ b/src/tribler/ui/src/pages/Settings/Versions.tsx @@ -14,24 +14,24 @@ export default function Versions() { const [canUpgrade, setCanUpgrade] = useState(false); const [isUpgrading, setIsUpgrading] = useState(false); - const clickedImport = (e, old_version?) => { + const clickedImport = (e: React.MouseEvent, old_version: string) => { triblerService.performUpgrade(); setIsUpgrading(true); } - const clickedRemove = (e, old_version?) => { + const clickedRemove = (e: React.MouseEvent, old_version: string) => { triblerService.removeVersion(old_version); setVersions(versions.filter((v) => v != old_version)); } - const useMountEffect = (fun) => useEffect(fun, []) + const useMountEffect = (fun: React.EffectCallback) => useEffect(fun, []) useMountEffect(() => { (async () => { const version = await triblerService.getVersion(); setVersion(version); var allVersions = await triblerService.getVersions(); - const versions = (allVersions.versions).filter((v) => v != allVersions.current); + const versions = (allVersions.versions).filter((v: number) => v != allVersions.current); setVersions(versions); const newVersion = await triblerService.getNewVersion(); @@ -71,7 +71,7 @@ export default function Versions() { { - versions.reduce((r, e) => r.push(e, e, e, e) && r, []).map(function(old_version, i){ + versions.reduce((r, e) => r.push(e, e, e, e) && r, []).map(function(old_version: string, i: number){ switch (i % 4){ case 0: { return () @@ -81,8 +81,8 @@ export default function Versions() { } case 2: { return ( - canUpgrade == old_version ? ( - isUpgrading ?
+ (typeof canUpgrade === "string") && (canUpgrade == old_version) ? ( + isUpgrading ?
: ) : ) diff --git a/src/tribler/ui/src/services/tribler.service.ts b/src/tribler/ui/src/services/tribler.service.ts index 62fa1997a9..1c8feb0ebd 100644 --- a/src/tribler/ui/src/services/tribler.service.ts +++ b/src/tribler/ui/src/services/tribler.service.ts @@ -198,7 +198,7 @@ export class TriblerService { return (await this.http.post(`/versioning/upgrade`)) } - async removeVersion(version_str) { + async removeVersion(version_str: string) { return (await this.http.delete(`/versioning/versions/${version_str}`)) }