Skip to content
This repository was archived by the owner on Sep 10, 2022. It is now read-only.

Commit 60007f6

Browse files
committed
Merge pull request #32 from addyosmani/toast-support
Removing files we don't need and adding in toast support
2 parents 9f56fd0 + 1e52e2b commit 60007f6

File tree

10 files changed

+49
-580
lines changed

10 files changed

+49
-580
lines changed

gulp-tasks/service-worker.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ gulp.task('service-worker', function(cb) {
3636
GLOBAL.config.dest + '/manifest.json'
3737
],
3838
dynamicUrlToDependencies: {
39-
'/app-shell': ['server/layouts/app-shell.handlebars'],
39+
'/app-shell': ['server/views/layouts/app-shell.handlebars'],
4040
'/partials/': [
41-
'server/layouts/partial.handlebars',
41+
'server/views/layouts/partial.handlebars',
4242
'server/views/index.handlebars'
4343
],
4444
'/partials/url-1': [
45-
'server/layouts/partial.handlebars',
45+
'server/views/layouts/partial.handlebars',
4646
'server/views/url-1.handlebars'
4747
],
4848
'/partials/url-2': [
49-
'server/layouts/partial.handlebars',
49+
'server/views/layouts/partial.handlebars',
5050
'server/views/url-2.handlebars'
5151
]
5252
},

server/views/layouts/app-shell.handlebars

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ limitations under the License.
6464
</div>
6565
</section>
6666

67+
<aside class="toast-view js-toast-view"></aside>
68+
6769
<!-- Loading Dialog For use by Activities -->
6870
<div class="loader js-global-loader is-hidden">
6971
<svg viewBox="0 0 32 32" width="32" height="32">

server/views/layouts/default.handlebars

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ limitations under the License.
6161
</div>
6262
</section>
6363

64+
<aside class="toast-view js-toast-view"></aside>
65+
6466
{{> async-css }}
6567

6668
{{#each remoteScripts}}

src/scripts/config/Config.js

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

src/scripts/controller/Controller.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
import ToasterSingleton from '../libs/ToasterSingleton';
19+
1820
export default class Controller {
1921

2022
constructor(registerServiceWorker = true) {
@@ -33,6 +35,33 @@ export default class Controller {
3335
scope: '/'
3436
}).then((registration) => {
3537
console.log('Service worker is registered.');
38+
39+
var isUpdate = false;
40+
41+
// If this fires we should check if there's a new Service Worker
42+
// waiting to be activated. If so, ask the user to force refresh.
43+
if (registration.active) {
44+
isUpdate = true;
45+
}
46+
47+
registration.onupdatefound = function(updateEvent) {
48+
console.log('A new Service Worker version has been found...');
49+
50+
// If an update is found the spec says that there is a new Service
51+
// Worker installing, so we should wait for that to complete then
52+
// show a notification to the user.
53+
registration.installing.onstatechange = function(event) {
54+
if (this.state === 'installed') {
55+
if (isUpdate) {
56+
ToasterSingleton.getToaster().toast(
57+
'App updated. Restart for the new version.');
58+
} else {
59+
ToasterSingleton.getToaster().toast(
60+
'App ready for offline use.');
61+
}
62+
}
63+
};
64+
};
3665
})
3766
.catch((err) => {
3867
console.log('Unable to register service worker.', err);

src/scripts/libs/ConfigManager.js

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

0 commit comments

Comments
 (0)