Previouly, whenever a new ServiceWorker update was detected the user was prompted to update (with a notification). This turned out to be more distracting than helpful. Also, one would get notifications on all open browser tabs/windows and had to manually reload each one in order for the whole content (including the app) to be updated. This commit changes the update strategy as follows: - Whenever a new update is detected, it is immediately activated (and all tabs/windows will be notified). - Once an update is activated (regardless of whether the activation was initiated by the current tab/window or not), a flag will be set to do a "full page navigation" the next time the user navigates to a document. Benefits: - All tabs/windows are updated asap. - The updates are applied authomatically, without the user's needing to do anything. - The updates are applied in a way that: a. Ensures that the app and content versions are always compatible. b. Does not distract the user from their usual workflow. NOTE: The "full page navigation" may cause a flash (while the page is loading from scratch), but this is expected to be minimal, since at that point almost all necessary resources are cached by and served from the ServiceWorker. Fixes #17539
68 lines
2.4 KiB
TypeScript
68 lines
2.4 KiB
TypeScript
import { NgModule } from '@angular/core';
|
|
import { CommonModule } from '@angular/common';
|
|
|
|
import { ContributorService } from './contributor/contributor.service';
|
|
import { CopierService } from 'app/shared/copier.service';
|
|
import { PrettyPrinter } from './code/pretty-printer.service';
|
|
|
|
// Any components that we want to use inside embedded components must be declared or imported here
|
|
// It is not enough just to import them inside the AppModule
|
|
|
|
// Reusable components (used inside embedded components)
|
|
import { MdIconModule, MdSnackBarModule, MdTabsModule } from '@angular/material';
|
|
import { CodeComponent } from './code/code.component';
|
|
import { SharedModule } from 'app/shared/shared.module';
|
|
|
|
// Embedded Components
|
|
import { ApiListComponent } from './api/api-list.component';
|
|
import { CodeExampleComponent } from './code/code-example.component';
|
|
import { CodeTabsComponent } from './code/code-tabs.component';
|
|
import { ContributorListComponent } from './contributor/contributor-list.component';
|
|
import { ContributorComponent } from './contributor/contributor.component';
|
|
import { CurrentLocationComponent } from './current-location.component';
|
|
import { LiveExampleComponent, EmbeddedPlunkerComponent } from './live-example/live-example.component';
|
|
import { ResourceListComponent } from './resource/resource-list.component';
|
|
import { ResourceService } from './resource/resource.service';
|
|
import { TocComponent } from './toc/toc.component';
|
|
|
|
/** Components that can be embedded in docs
|
|
* such as CodeExampleComponent, LiveExampleComponent,...
|
|
*/
|
|
export const embeddedComponents: any[] = [
|
|
ApiListComponent, CodeExampleComponent, CodeTabsComponent, ContributorListComponent,
|
|
CurrentLocationComponent, LiveExampleComponent, ResourceListComponent, TocComponent
|
|
];
|
|
|
|
/** Injectable class w/ property returning components that can be embedded in docs */
|
|
export class EmbeddedComponents {
|
|
components = embeddedComponents;
|
|
}
|
|
|
|
@NgModule({
|
|
imports: [
|
|
CommonModule,
|
|
MdIconModule,
|
|
MdSnackBarModule,
|
|
MdTabsModule,
|
|
SharedModule
|
|
],
|
|
declarations: [
|
|
embeddedComponents,
|
|
CodeComponent,
|
|
ContributorComponent,
|
|
EmbeddedPlunkerComponent
|
|
],
|
|
exports: [
|
|
TocComponent
|
|
],
|
|
providers: [
|
|
ContributorService,
|
|
CopierService,
|
|
EmbeddedComponents,
|
|
PrettyPrinter,
|
|
ResourceService
|
|
],
|
|
entryComponents: [ embeddedComponents ]
|
|
})
|
|
export class EmbeddedModule { }
|