Skip to content

Commit af09d77

Browse files
Nateowamimarksvc
authored andcommitted
SF-3532 Dispose realtime docs when no longer in use
1 parent f38ae20 commit af09d77

File tree

132 files changed

+3364
-2021
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+3364
-2021
lines changed

src/SIL.XForge.Scripture/ClientApp/e2e/workflows/community-checking.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ async function joinAsChecker(
174174
// Give time for the last answer to be saved
175175
await page.waitForTimeout(500);
176176
} catch (e) {
177+
if (preset.pauseOnFailure) await page.pause();
177178
console.error('Error running tests for checker ' + userNumber);
178179
console.error(e);
179180
await screenshot(

src/SIL.XForge.Scripture/ClientApp/src/app/app-routing.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { ServalAdminAuthGuard } from './serval-administration/serval-admin-auth.
1414
import { ServalAdministrationComponent } from './serval-administration/serval-administration.component';
1515
import { ServalProjectComponent } from './serval-administration/serval-project.component';
1616
import { SettingsComponent } from './settings/settings.component';
17+
import { BlankPageComponent } from './shared/blank-page/blank-page.component';
1718
import { PageNotFoundComponent } from './shared/page-not-found/page-not-found.component';
1819
import { SettingsAuthGuard, SyncAuthGuard } from './shared/project-router.guard';
1920
import { SyncComponent } from './sync/sync.component';
@@ -33,6 +34,7 @@ const routes: Routes = [
3334
{ path: 'serval-administration/:projectId', component: ServalProjectComponent, canActivate: [ServalAdminAuthGuard] },
3435
{ path: 'serval-administration', component: ServalAdministrationComponent, canActivate: [ServalAdminAuthGuard] },
3536
{ path: 'system-administration', component: SystemAdministrationComponent, canActivate: [SystemAdminAuthGuard] },
37+
{ path: 'blank-page', component: BlankPageComponent },
3638
{ path: '**', component: PageNotFoundComponent }
3739
];
3840

src/SIL.XForge.Scripture/ClientApp/src/app/app.component.spec.ts

Lines changed: 108 additions & 78 deletions
Large diffs are not rendered by default.

src/SIL.XForge.Scripture/ClientApp/src/app/app.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { FileService } from 'xforge-common/file.service';
2424
import { I18nService } from 'xforge-common/i18n.service';
2525
import { LocationService } from 'xforge-common/location.service';
2626
import { Breakpoint, MediaBreakpointService } from 'xforge-common/media-breakpoints/media-breakpoint.service';
27+
import { DocSubscription } from 'xforge-common/models/realtime-doc';
2728
import { UserDoc } from 'xforge-common/models/user-doc';
2829
import { NoticeService } from 'xforge-common/notice.service';
2930
import { OnlineStatusService } from 'xforge-common/online-status.service';
@@ -283,7 +284,8 @@ export class AppComponent extends DataLoadingComponent implements OnInit, OnDest
283284
this.userService.setCurrentProjectId(this.currentUserDoc!, this._selectedProjectDoc.id);
284285
this.projectUserConfigDoc = await this.projectService.getUserConfig(
285286
this._selectedProjectDoc.id,
286-
this.currentUserDoc!.id
287+
this.currentUserDoc!.id,
288+
new DocSubscription('AppComponent', this.destroyRef)
287289
);
288290
if (this.selectedProjectDeleteSub != null) {
289291
this.selectedProjectDeleteSub.unsubscribe();

src/SIL.XForge.Scripture/ClientApp/src/app/app.module.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { OverlayContainer } from '@angular/cdk/overlay';
22
import { DatePipe } from '@angular/common';
33
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
4-
import { APP_ID, ErrorHandler, NgModule, inject, provideAppInitializer } from '@angular/core';
4+
import { APP_ID, ErrorHandler, inject, NgModule, provideAppInitializer } from '@angular/core';
55
import { MatRipple } from '@angular/material/core';
66
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
77
import { ServiceWorkerModule } from '@angular/service-worker';
@@ -37,6 +37,7 @@ import { ProjectComponent } from './project/project.component';
3737
import { ScriptureChooserDialogComponent } from './scripture-chooser-dialog/scripture-chooser-dialog.component';
3838
import { DeleteProjectDialogComponent } from './settings/delete-project-dialog/delete-project-dialog.component';
3939
import { SettingsComponent } from './settings/settings.component';
40+
import { CacheService } from './shared/cache-service/cache.service';
4041
import { GlobalNoticesComponent } from './shared/global-notices/global-notices.component';
4142
import { SharedModule } from './shared/shared.module';
4243
import { TextNoteDialogComponent } from './shared/text/text-note-dialog/text-note-dialog.component';
@@ -46,6 +47,11 @@ import { LynxInsightsModule } from './translate/editor/lynx/insights/lynx-insigh
4647
import { TranslateModule } from './translate/translate.module';
4748
import { UsersModule } from './users/users.module';
4849

50+
/** Initialization function for any services that need to be run but are not depended on by any component. */
51+
function initializeGlobalServicesFactory(_cacheService: CacheService): () => Promise<any> {
52+
return () => Promise.resolve();
53+
}
54+
4955
@NgModule({
5056
declarations: [
5157
AppComponent,
@@ -97,6 +103,10 @@ import { UsersModule } from './users/users.module';
97103
{ provide: ErrorHandler, useClass: ExceptionHandlingService },
98104
{ provide: OverlayContainer, useClass: InAppRootOverlayContainer },
99105
provideHttpClient(withInterceptorsFromDi()),
106+
provideAppInitializer(() => {
107+
const initializerFn = initializeGlobalServicesFactory(inject(CacheService));
108+
return initializerFn();
109+
}),
100110
provideAppInitializer(() => {
101111
const initializerFn = preloadEnglishTranslations(inject(TranslocoService));
102112
return initializerFn();

src/SIL.XForge.Scripture/ClientApp/src/app/checking/chapter-audio-dialog/chapter-audio-dialog.component.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,18 +368,18 @@ describe('ChapterAudioDialogComponent', () => {
368368
expect(result.timingData[1].to).toEqual(1.296);
369369
}));
370370

371-
it('will not save or upload if there is no audio', fakeAsync(() => {
371+
it('will not save or upload if there is no audio', fakeAsync(async () => {
372372
env.component.prepareTimingFileUpload(env.timingFile);
373-
env.component.save();
373+
await env.component.save();
374374
env.fixture.detectChanges();
375375

376376
expect(env.numberOfTimesDialogClosed).toEqual(0);
377377
expect(env.wrapperAudio.classList.contains('invalid')).toBe(true);
378378
}));
379379

380-
it('will not save or upload if there is no timing data', fakeAsync(() => {
380+
it('will not save or upload if there is no timing data', fakeAsync(async () => {
381381
env.component.audioUpdate(env.audioFile);
382-
env.component.save();
382+
await env.component.save();
383383
env.fixture.detectChanges();
384384

385385
expect(env.numberOfTimesDialogClosed).toEqual(0);
@@ -478,15 +478,15 @@ describe('ChapterAudioDialogComponent', () => {
478478
expect(env.wrapperTiming.classList.contains('valid')).toBe(true);
479479
}));
480480

481-
it('will not try to save dialog if offline', fakeAsync(() => {
481+
it('will not try to save dialog if offline', fakeAsync(async () => {
482482
env.onlineStatus = false;
483483
env.component.audioUpdate(env.audioFile);
484484
tick();
485485
env.component.prepareTimingFileUpload(env.timingFile);
486486
tick();
487487

488488
// SUT
489-
env.component.save();
489+
await env.component.save();
490490
tick();
491491
env.fixture.detectChanges();
492492
flush();

0 commit comments

Comments
 (0)