Skip to content

Commit 044c756

Browse files
committed
Displays active version
1 parent b3bf91c commit 044c756

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

src/app/panels/byond/byond.component.html

+14-9
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,20 @@
2727

2828
<ul>
2929
@for (version of byondService.versions; track version[0]) {
30-
{{ version[0] }} ({{ statusToMessage[version[1]] }})
31-
<button
32-
tuiButton
33-
appearance="primary"
34-
size="xs"
35-
(click)="byondService.setActive(version[0])"
36-
>
37-
Set active
38-
</button>
30+
{{ version[0] }}
31+
@if (version[0] === byondService.activeVersion) {
32+
(Active)
33+
} @else {
34+
({{ statusToMessage[version[1]] }})
35+
<button
36+
tuiButton
37+
appearance="primary"
38+
size="xs"
39+
(click)="byondService.setActive(version[0])"
40+
>
41+
Set active
42+
</button>
43+
}
3944
<button
4045
tuiButton
4146
appearance="secondary-destructive"

src/vm/byond.service.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ export enum VersionStatus {
1919
export class ByondService {
2020
public latestVersion: Promise<{ beta?: string; stable: string }>;
2121
private lock = new SharedLock();
22-
private active: string | null = null;
22+
23+
private _activeVersion: string | null = null;
24+
public get activeVersion() {
25+
return this._activeVersion;
26+
}
27+
2328
public deleteVersion = this.lock.wrap(async (version: string) => {
2429
const installs = await this.getByondFolder();
2530
await installs.removeEntry(version.toString());
@@ -28,7 +33,7 @@ export class ByondService {
2833
'/bin/rm',
2934
`-rf\0/var/lib/byond/${version}.zip\0/var/lib/byond/${version}`,
3035
);
31-
if (this.active === version) this.active = null;
36+
if (this._activeVersion === version) this._activeVersion = null;
3237
});
3338

3439
private _versions = new Map<string, VersionStatus>();
@@ -58,7 +63,7 @@ export class ByondService {
5863
`/mnt/host/byond/${version}.zip`,
5964
);
6065
this._versions.set(version, VersionStatus.Loaded);
61-
this.active = version;
66+
this._activeVersion = version;
6267
} catch (e) {
6368
this._versions.set(version, VersionStatus.Fetched);
6469
await this.commandQueueService.runToCompletion(
@@ -131,7 +136,7 @@ export class ByondService {
131136

132137
public useActive<T extends (path: string | null) => any>(fn: T) {
133138
this.lock.run(() =>
134-
fn(this.active ? `/var/lib/byond/${this.active}/` : null),
139+
fn(this._activeVersion ? `/var/lib/byond/${this._activeVersion}/` : null),
135140
);
136141
}
137142
}

0 commit comments

Comments
 (0)