Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Versioning TypeScript types #8100

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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