Update Notification Refactor (#511)
* Replaced profile links to anchors so we can open in new tab if we like * Refactored how update checking works. We now explicitly check and send back on the same API. We have a weekly job that will push an update to the user. * Implemented a changelog tab * Ported over a GA fix for using ' in PR bodies. * Don't check cert for Github
This commit is contained in:
parent
0e48aeebc5
commit
2a76092566
21 changed files with 246 additions and 56 deletions
|
|
@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
|
|||
import { HubConnection, HubConnectionBuilder } from '@microsoft/signalr';
|
||||
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { User } from '@sentry/angular';
|
||||
import { BehaviorSubject, ReplaySubject } from 'rxjs';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { UpdateNotificationModalComponent } from '../shared/update-notification/update-notification-modal.component';
|
||||
|
||||
|
|
@ -9,6 +10,11 @@ export enum EVENTS {
|
|||
UpdateAvailable = 'UpdateAvailable'
|
||||
}
|
||||
|
||||
export interface Message<T> {
|
||||
event: EVENTS;
|
||||
payload: T;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
|
|
@ -17,6 +23,9 @@ export class MessageHubService {
|
|||
private hubConnection!: HubConnection;
|
||||
private updateNotificationModalRef: NgbModalRef | null = null;
|
||||
|
||||
private messagesSource = new ReplaySubject<Message<any>>(1);
|
||||
public messages$ = this.messagesSource.asObservable();
|
||||
|
||||
constructor(private modalService: NgbModal) { }
|
||||
|
||||
createHubConnection(user: User) {
|
||||
|
|
@ -36,6 +45,10 @@ export class MessageHubService {
|
|||
});
|
||||
|
||||
this.hubConnection.on(EVENTS.UpdateAvailable, resp => {
|
||||
this.messagesSource.next({
|
||||
event: EVENTS.UpdateAvailable,
|
||||
payload: resp.body
|
||||
});
|
||||
// Ensure only 1 instance of UpdateNotificationModal can be open at once
|
||||
if (this.updateNotificationModalRef != null) { return; }
|
||||
this.updateNotificationModalRef = this.modalService.open(UpdateNotificationModalComponent, { scrollable: true, size: 'lg' });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue