From 4ec2b21fced6c9815c5ded3afdb5f2738542f225 Mon Sep 17 00:00:00 2001 From: Ben <43026681+bwp91@users.noreply.github.com> Date: Sat, 26 Oct 2024 11:38:48 +0100 Subject: [PATCH] perform a full restart when updating `homebridge` --- CHANGELOG.md | 1 + .../restart-homebridge.component.ts | 27 ++++++++++++++++--- .../manage-plugin/manage-plugin.component.ts | 3 ++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7de6bf80..8afa88a8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ Plugin developers: - check for service mode when querying child bridge status - enable strict config validation for the UI - bump the default node version from 20 to 22 +- perform a full restart when updating `homebridge` ### Homebridge Dependencies diff --git a/ui/src/app/core/components/restart-homebridge/restart-homebridge.component.ts b/ui/src/app/core/components/restart-homebridge/restart-homebridge.component.ts index d76edbd31..8cbc058fa 100644 --- a/ui/src/app/core/components/restart-homebridge/restart-homebridge.component.ts +++ b/ui/src/app/core/components/restart-homebridge/restart-homebridge.component.ts @@ -1,18 +1,39 @@ -import { Component } from '@angular/core' +import { ApiService } from '@/app/core/api.service' +import { Component, Input } from '@angular/core' import { Router } from '@angular/router' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' +import { TranslateService } from '@ngx-translate/core' +import { ToastrService } from 'ngx-toastr' @Component({ templateUrl: './restart-homebridge.component.html', }) export class RestartHomebridgeComponent { + @Input() fullRestart = false + constructor( public $activeModal: NgbActiveModal, + private $api: ApiService, private $router: Router, + private $toastr: ToastrService, + private $translate: TranslateService, ) {} public onRestartHomebridgeClick() { - this.$router.navigate(['/restart']) - this.$activeModal.close() + if (!this.fullRestart) { + this.$router.navigate(['/restart']) + this.$activeModal.close() + return + } + + this.$api.put('/platform-tools/hb-service/set-full-service-restart-flag', {}).subscribe({ + next: () => { + this.$router.navigate(['/restart']) + }, + error: (error) => { + console.error(error) + this.$toastr.error(error.message, this.$translate.instant('toast.title_error')) + }, + }) } } diff --git a/ui/src/app/core/manage-plugins/manage-plugin/manage-plugin.component.ts b/ui/src/app/core/manage-plugins/manage-plugin/manage-plugin.component.ts index d4f9a2014..a859f3aa1 100644 --- a/ui/src/app/core/manage-plugins/manage-plugin/manage-plugin.component.ts +++ b/ui/src/app/core/manage-plugins/manage-plugin/manage-plugin.component.ts @@ -225,10 +225,11 @@ export class ManagePluginComponent implements OnInit, OnDestroy { }).subscribe({ next: () => { this.$activeModal.close() - this.$modal.open(RestartHomebridgeComponent, { + const ref = this.$modal.open(RestartHomebridgeComponent, { size: 'lg', backdrop: 'static', }) + ref.componentInstance.fullRestart = true }, error: (error) => { this.actionFailed = true