Skip to content

Commit 0c38835

Browse files
fix(service-worker): remove service worker (#90)
* fix(service-worker): remove service worker * chore(angular): remove unneeded copy files * fix(service-worker): readd manifest with angular 8 * fix(service-worker): remove ngsw paths
1 parent 828edd7 commit 0c38835

File tree

8 files changed

+74
-180
lines changed

8 files changed

+74
-180
lines changed

Phonebook.Frontend/angular.json

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,15 @@
1919
"assets": [
2020
"src/assets",
2121
"src/favicon.ico",
22-
"src/services",
23-
"src/manifest.json",
24-
"src/changelog.md"
22+
"src/changelog.md",
23+
"src/manifest.webmanifest"
2524
],
2625
"styles": [
2726
"src/styles.scss",
2827
"src/fonts/fonts.css",
2928
"src/fonts/materialicons/material-icons.css"
3029
],
3130
"scripts": [],
32-
"ngswConfigPath": "src/ngsw-config.json",
3331
"stylePreprocessorOptions": {
3432
"includePaths": [
3533
"src/styles"
@@ -43,8 +41,7 @@
4341
"aot": true,
4442
"extractLicenses": true,
4543
"vendorChunk": false,
46-
"buildOptimizer": false,
47-
"serviceWorker": true
44+
"buildOptimizer": false
4845
},
4946
"configurations": {
5047
"en": {
@@ -87,9 +84,8 @@
8784
"assets": [
8885
"src/assets",
8986
"src/favicon.ico",
90-
"src/services",
91-
"src/manifest.json",
92-
"src/changelog.md"
87+
"src/changelog.md",
88+
"src/manifest.webmanifest"
9389
],
9490
"styles": [
9591
"src/styles.scss",
@@ -102,7 +98,6 @@
10298
"src/styles"
10399
]
104100
},
105-
"ngswConfigPath": "src/ngsw-config.json",
106101
"optimization": true,
107102
"outputHashing": "all",
108103
"sourceMap": false,
@@ -112,7 +107,6 @@
112107
"extractLicenses": true,
113108
"vendorChunk": false,
114109
"buildOptimizer": true,
115-
"serviceWorker": true,
116110
"fileReplacements": [
117111
{
118112
"replace": "src/environments/environment.ts",
@@ -127,25 +121,22 @@
127121
"i18nLocale": "en",
128122
"i18nMissingTranslation": "error",
129123
"outputPath": "dist/en",
130-
"baseHref": "/en/",
131-
"ngswConfigPath": "src/ngsw-config.en.json"
124+
"baseHref": "/en/"
132125
},
133126
"de": {
134127
"i18nFile": "src/i18n/messages.de.xlf",
135128
"i18nFormat": "xlf",
136129
"i18nLocale": "de",
137130
"i18nMissingTranslation": "error",
138131
"outputPath": "dist/de",
139-
"baseHref": "/de/",
140-
"ngswConfigPath": "src/ngsw-config.de.json"
132+
"baseHref": "/de/"
141133
},
142134
"preview": {
143135
"i18nFile": "src/i18n/messages.de.xlf",
144136
"i18nFormat": "xlf",
145137
"i18nLocale": "de",
146138
"i18nMissingTranslation": "error",
147-
"outputPath": "dist/",
148-
"serviceWorker": false
139+
"outputPath": "dist/"
149140
}
150141
}
151142
},
@@ -192,8 +183,7 @@
192183
"assets": [
193184
"src/assets",
194185
"src/favicon.ico",
195-
"src/services",
196-
"src/manifest.json"
186+
"src/manifest.webmanifest"
197187
],
198188
"stylePreprocessorOptions": {
199189
"includePaths": [

Phonebook.Frontend/src/app/app.component.ts

Lines changed: 62 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -26,72 +26,76 @@ export class AppComponent implements OnInit {
2626
private snackBar: MatSnackBar,
2727
private releaseMigrationService: ReleaseInfoService,
2828
private store: Store,
29-
private swUpdates: SwUpdate,
29+
// Commented as long as serviceWorker is reinstalled
30+
// Issue: https://github.com/T-Systems-MMS/phonebook/issues/87
31+
// private swUpdates: SwUpdate,
3032
private matDialog: MatDialog,
3133
private i18n: I18n,
3234
private platform: Platform
3335
) {}
3436

3537
public ngOnInit() {
3638
this.store.dispatch(new InitTheme());
37-
// Checking if the Service Worker was installed correctly.
38-
if (!this.store.selectSnapshot(AppState.serviceWorkerNotificationDisplayed)) {
39-
if ('serviceWorker' in navigator) {
40-
this.swUpdates.activated.subscribe(active => {
41-
if (active.current) {
42-
this.snackBar.open(
43-
this.i18n({
44-
value: 'Hurray! You can use this Website offline.',
45-
description: 'Message indicating the service worker was successfully installed',
46-
id: 'AppComponentServiceWorkerSuccessMessage',
47-
meaning: 'AppComponent'
48-
}),
49-
'',
50-
{ duration: 3000 }
51-
);
52-
this.store.dispatch(new ServiceWorkerNotificationDisplayed());
53-
}
54-
});
55-
} else {
56-
this.snackBar.open(
57-
this.i18n({
58-
value: 'Your Browser does not support Offline Apps!',
59-
description: 'Message indicating the service worker was not installed',
60-
id: 'AppComponentServiceWorkerErrorMessage',
61-
meaning: 'AppComponent'
62-
}),
63-
'',
64-
{
65-
duration: 3000
66-
}
67-
);
68-
this.store.dispatch(new ServiceWorkerNotificationDisplayed());
69-
}
70-
}
39+
// Commented as long as serviceWorker is reinstalled
40+
// Issue: https://github.com/T-Systems-MMS/phonebook/issues/87
41+
// //Checking if the Service Worker was installed correctly.
42+
// if (!this.store.selectSnapshot(AppState.serviceWorkerNotificationDisplayed)) {
43+
// if ('serviceWorker' in navigator) {
44+
// this.swUpdates.activated.subscribe(active => {
45+
// if (active.current) {
46+
// this.snackBar.open(
47+
// this.i18n({
48+
// value: 'Hurray! You can use this Website offline.',
49+
// description: 'Message indicating the service worker was successfully installed',
50+
// id: 'AppComponentServiceWorkerSuccessMessage',
51+
// meaning: 'AppComponent'
52+
// }),
53+
// '',
54+
// { duration: 3000 }
55+
// );
56+
// this.store.dispatch(new ServiceWorkerNotificationDisplayed());
57+
// }
58+
// });
59+
// } else {
60+
// this.snackBar.open(
61+
// this.i18n({
62+
// value: 'Your Browser does not support Offline Apps!',
63+
// description: 'Message indicating the service worker was not installed',
64+
// id: 'AppComponentServiceWorkerErrorMessage',
65+
// meaning: 'AppComponent'
66+
// }),
67+
// '',
68+
// {
69+
// duration: 3000
70+
// }
71+
// );
72+
// this.store.dispatch(new ServiceWorkerNotificationDisplayed());
73+
// }
74+
// }
7175

72-
// Check if a new Update for the Service worker is available
73-
if (this.swUpdates.isEnabled) {
74-
this.swUpdates.available.subscribe(() => {
75-
const updateNotification = this.snackBar.open(
76-
this.i18n({
77-
value: 'A newer version is available. Do you want to update straight away?',
78-
description: 'Message indicating the app can be updated and question if it should be updated',
79-
id: 'AppComponentServiceWorkerUpdateMessage',
80-
meaning: 'AppComponent'
81-
}),
82-
this.i18n({
83-
value: 'Update!',
84-
description: 'Button Text for updating the app',
85-
id: 'AppComponentServiceWorkerUpdateButtonMessage',
86-
meaning: 'AppComponent'
87-
}),
88-
{ duration: 4000 }
89-
);
90-
updateNotification.onAction().subscribe(onAction => {
91-
window.location.reload();
92-
});
93-
});
94-
}
76+
// // Check if a new Update for the Service worker is available
77+
// if (this.swUpdates.isEnabled) {
78+
// this.swUpdates.available.subscribe(() => {
79+
// const updateNotification = this.snackBar.open(
80+
// this.i18n({
81+
// value: 'A newer version is available. Do you want to update straight away?',
82+
// description: 'Message indicating the app can be updated and question if it should be updated',
83+
// id: 'AppComponentServiceWorkerUpdateMessage',
84+
// meaning: 'AppComponent'
85+
// }),
86+
// this.i18n({
87+
// value: 'Update!',
88+
// description: 'Button Text for updating the app',
89+
// id: 'AppComponentServiceWorkerUpdateButtonMessage',
90+
// meaning: 'AppComponent'
91+
// }),
92+
// { duration: 4000 }
93+
// );
94+
// updateNotification.onAction().subscribe(onAction => {
95+
// window.location.reload();
96+
// });
97+
// });
98+
// }
9599

96100
// Ask for Permission to send Bug reports
97101
const test = this.store.selectSnapshot(AppState.sendFeedback);

Phonebook.Frontend/src/app/app.module.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//Angular Imports
22
import { BrowserModule } from '@angular/platform-browser';
33
import { NgModule, ErrorHandler, TRANSLATIONS, LOCALE_ID } from '@angular/core';
4-
import { ServiceWorkerModule } from '@angular/service-worker';
54
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
65
import { HttpClientModule } from '@angular/common/http';
76
import { environment } from 'src/environments/environment';
@@ -107,9 +106,6 @@ declare const require;
107106
FeatureFlagModule,
108107
NotImplementedModule,
109108
FeedbackDrawerModule,
110-
ServiceWorkerModule.register('./ngsw-worker.js', {
111-
enabled: environment.production
112-
}),
113109
NgxsModule.forRoot([AppState, BookmarksState, LastPersonsState, CommonPersonsState, SearchState, TableState]),
114110
NgxsStoragePluginModule.forRoot({
115111
key: ['appstate', 'bookmarks', 'commonpersons', 'lastpersons', 'tablestate']

Phonebook.Frontend/src/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
<link rel="search" type="application/opensearchdescription+xml" title="Phonebook Search"
2323
href="assets/opensearch.xml" />
2424

25+
<link rel="manifest" href="manifest.webmanifest">
26+
<meta name="theme-color" content="#1976d2">
2527
<meta name="viewport" content="width=device-width, initial-scale=1">
2628
<link rel="icon" type="image/x-icon" href="favicon.ico">
27-
<link rel="manifest" href="manifest.json">
28-
<meta name="theme-color" content="#1976d2">
2929
</head>
3030

3131
<body class="mat-typography">

Phonebook.Frontend/src/manifest.json renamed to Phonebook.Frontend/src/manifest.webmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@
4848
"type": "image/png"
4949
}
5050
]
51-
}
51+
}

Phonebook.Frontend/src/ngsw-config.de.json

Lines changed: 0 additions & 32 deletions
This file was deleted.

Phonebook.Frontend/src/ngsw-config.en.json

Lines changed: 0 additions & 32 deletions
This file was deleted.

Phonebook.Frontend/src/ngsw-config.json

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)