added check for updates link

This commit is contained in:
Nicolas Constant 2020-03-07 00:31:14 -05:00
parent 49887613c8
commit 4d461b497e
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
4 changed files with 29 additions and 3 deletions

View File

@ -55,7 +55,11 @@
</div>
<h4 class="panel__subtitle">About</h4>
<p class="version">Sengi version: {{version}}</p>
<p class="version">
Sengi version: {{version}}<br/>
<a href class="version__link" (click)="checkForUpdates()">check for updates</a>
</p>
<h4 class="panel__subtitle">RESET</h4>
<div class="sub-section">

View File

@ -17,6 +17,14 @@
.version {
display: block;
padding: 0 5px;
&__link {
color: rgb(161, 161, 161);
&:hover {
color: #fff;
}
}
}
.sub-section {

View File

@ -5,6 +5,7 @@ import { Howl } from 'howler';
import { environment } from '../../../../environments/environment';
import { ToolsService } from '../../../services/tools.service';
import { UserNotificationService, NotificationSoundDefinition } from '../../../services/user-notification.service';
import { ServiceWorkerService } from '../../../services/service-worker.service';
@Component({
selector: 'app-settings',
@ -28,6 +29,7 @@ export class SettingsComponent implements OnInit {
constructor(
private formBuilder: FormBuilder,
private serviceWorkersService: ServiceWorkerService,
private readonly toolsService: ToolsService,
private readonly userNotificationsService: UserNotificationService) { }
@ -119,6 +121,11 @@ export class SettingsComponent implements OnInit {
this.isCleanningAll = false;
return false;
}
checkForUpdates(): boolean {
this.serviceWorkersService.checkForUpdates();
return false;
}
}

View File

@ -7,12 +7,11 @@ import { interval, concat, BehaviorSubject } from 'rxjs';
providedIn: 'root'
})
export class ServiceWorkerService {
newAppVersionIsAvailable = new BehaviorSubject<boolean>(false);
private isListening = false;
constructor(appRef: ApplicationRef, updates: SwUpdate) {
constructor(appRef: ApplicationRef, private updates: SwUpdate) {
//https://angular.io/guide/service-worker-communications
@ -46,4 +45,12 @@ export class ServiceWorkerService {
loadNewAppVersion() {
document.location.reload();
}
checkForUpdates(): any {
console.log("Check for update");
this.updates.checkForUpdate()
.catch(err => {
console.error(err);
});
}
}