Skip to content

Commit

Permalink
next try on child bridges
Browse files Browse the repository at this point in the history
  • Loading branch information
bwp91 committed Nov 9, 2023
1 parent 2c552aa commit 2760b97
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h3 class="text-center primary-text" [translate]="'platform.version.title_servic
</p>
<div class="text-center">
<button type="button" class="btn btn-primary"
*ngIf="!['homebridge', 'homebridge-config-ui-x'].includes(pluginName) && hasChildBridges"
*ngIf="!['homebridge', 'homebridge-config-ui-x'].includes(pluginName) && childBridges.length > 0"
(click)="restartChildBridges()"
[translate]="'plugins.manage.child_bridge_button_restart_now'">Restart Child Bridges</button>
<button type="button" class="btn btn-primary" (click)="onRestartHomebridgeClick()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
public updateToBeta = false;
public changeLog: string;
public release: any;
public hasChildBridges = false;
public childBridges: any;

private toastSuccess: string;
public presentTenseVerb: string;
Expand Down Expand Up @@ -67,7 +67,12 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {

this.toastSuccess = this.$translate.instant('toast.title_success');
this.onlineUpdateOk = !(['homebridge', 'homebridge-config-ui-x'].includes(this.pluginName) && this.$settings.env.platform === 'win32');
this.hasChildBridges = this.getChildBridgeMetadata().length > 0;

const childBridgeIo = this.$ws.connectToNamespace('child-bridges');
childBridgeIo.request('get-homebridge-child-bridge-status').subscribe((data) => {
this.childBridges = data.filter((x: any) => x.pluginName === this.pluginName);
});
childBridgeIo.end();

switch (this.action) {
case 'Install':
Expand Down Expand Up @@ -233,17 +238,6 @@ export class ManagePluginsModalComponent implements OnInit, OnDestroy {
this.activeModal.close();
}

public getChildBridgeMetadata(): any[] {
const io = this.$ws.connectToNamespace('child-bridges');
const childBridges = [];
io.request('get-homebridge-child-bridge-status').subscribe((data) => {
childBridges.push(...data);
});
io.end();

return childBridges.filter((x) => x.pluginName === this.pluginName);
}

public async restartChildBridges() {
// const childBridges = this.getChildBridgeMetadata();
// const bridge = childBridges.find((x) => x.pluginName === this.pluginName);
Expand Down

0 comments on commit 2760b97

Please sign in to comment.