Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,25 @@ export class ProjectNotificationService {
private authService: AuthService,
private readonly onlineService: OnlineStatusService
) {
this.connection = new HubConnectionBuilder().withUrl('/project-notifications', this.options).build();
this.connection = new HubConnectionBuilder()
.withUrl('/project-notifications', this.options)
.withAutomaticReconnect()
.withStatefulReconnect()
.build();
}

get appOnline(): boolean {
return this.onlineService.isOnline && this.onlineService.isBrowserOnline;
}

removeNotifyBuildProgressHandler(handler: any): void {
this.connection.off('notifyBuildProgress', handler);
}

removeNotifySyncProgressHandler(handler: any): void {
this.connection.off('notifySyncProgress', handler);
}

setNotifyBuildProgressHandler(handler: any): void {
this.connection.on('notifyBuildProgress', handler);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ export class SyncProgressComponent {
private sourceProjectDoc?: SFProjectDoc;
private _projectDoc?: SFProjectDoc;

private readonly syncProgressHandler = (projectId: string, progressState: ProgressState): void =>
this.updateProgressState(projectId, progressState);

constructor(
private readonly projectService: SFProjectService,
private readonly projectNotificationService: ProjectNotificationService,
Expand All @@ -73,11 +76,10 @@ export class SyncProgressComponent {
private readonly onlineStatus: OnlineStatusService,
private destroyRef: DestroyRef
) {
this.projectNotificationService.setNotifySyncProgressHandler((projectId: string, progressState: ProgressState) => {
this.updateProgressState(projectId, progressState);
});
this.projectNotificationService.setNotifySyncProgressHandler(this.syncProgressHandler);
this.destroyRef.onDestroy(async () => {
await this.projectNotificationService.stop();
this.projectNotificationService.removeNotifySyncProgressHandler(this.syncProgressHandler);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export class DraftHistoryListComponent {
// This is just after SFv5.33.0 was released
readonly draftHistoryCutOffDate: Date = new Date('2025-06-03T21:00:00Z');
readonly draftHistoryCutOffDateFormatted: string = this.i18n.formatDate(this.draftHistoryCutOffDate);
private readonly notifyBuildProgressHandler = (projectId: string): void => {
this.loadHistory(projectId);
};

constructor(
activatedProject: ActivatedProjectService,
Expand All @@ -48,13 +51,12 @@ export class DraftHistoryListComponent {
await projectNotificationService.subscribeToProject(projectId);
// When build notifications are received, reload the build history
// NOTE: We do not need the build state, so just ignore it.
projectNotificationService.setNotifyBuildProgressHandler((projectId: string) => {
this.loadHistory(projectId);
});
projectNotificationService.setNotifyBuildProgressHandler(this.notifyBuildProgressHandler);
});
destroyRef.onDestroy(async () => {
// Stop the SignalR connection when the component is destroyed
await projectNotificationService.stop();
projectNotificationService.removeNotifyBuildProgressHandler(this.notifyBuildProgressHandler);
});
}

Expand Down
5 changes: 4 additions & 1 deletion src/SIL.XForge.Scripture/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,10 @@ IExceptionHandler exceptionHandler
{
endpoints.MapControllers();
endpoints.MapRazorPages();
endpoints.MapHub<NotificationHub>(pattern: $"/{UrlConstants.ProjectNotifications}");
endpoints.MapHub<NotificationHub>(
pattern: $"/{UrlConstants.ProjectNotifications}",
options => options.AllowStatefulReconnects = true
);
var authOptions = Configuration.GetOptions<AuthOptions>();
endpoints.MapHangfireDashboard(
new DashboardOptions
Expand Down
Loading