Skip to content

Commit

Permalink
Fixed Versioning TypeScript types
Browse files Browse the repository at this point in the history
  • Loading branch information
qstokkink committed Aug 20, 2024
1 parent e46f649 commit e1a06a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/tribler/ui/src/pages/Settings/Versions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLElement>, old_version: string) => {
triblerService.performUpgrade();
setIsUpgrading(true);
}

const clickedRemove = (e, old_version?) => {
const clickedRemove = (e: React.MouseEvent<HTMLElement>, 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();
Expand Down Expand Up @@ -71,7 +71,7 @@ export default function Versions() {
<Label></Label><Label></Label><Label></Label>

{
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 (<Label>{old_version}</Label>)
Expand All @@ -81,8 +81,8 @@ export default function Versions() {
}
case 2: {
return (
canUpgrade == old_version ? (
isUpgrading ? <div className="flex justify-center p-5 gap-1"><RefreshCw opacity="0.5" class="animate-spin duration-500" /><Label className="content-center text-muted-foreground">{t('VersionUpgrading')}...</Label></div>
(typeof canUpgrade === "string") && (canUpgrade == old_version) ? (
isUpgrading ? <div className="flex justify-center p-5 gap-1"><RefreshCw opacity="0.5" className="animate-spin duration-500" /><Label className="content-center text-muted-foreground">{t('VersionUpgrading')}...</Label></div>
: <Button variant="default" type="submit" onClick={(e) => clickedImport(e, old_version)}>{t('VersionImport')}</Button>)
: <Label></Label>
)
Expand Down
2 changes: 1 addition & 1 deletion src/tribler/ui/src/services/tribler.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`))
}

Expand Down

0 comments on commit e1a06a2

Please sign in to comment.