Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Commit

Permalink
feat(app): app will now ask if you want to leave and are offline
Browse files Browse the repository at this point in the history
closes #57
  • Loading branch information
seiyria committed Oct 14, 2015
1 parent 9ba7874 commit a991b07
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/js/services/disconnectNotifier.js
@@ -1,11 +1,13 @@
import site from '../app';

site.service('DisconnectNotifier', ($q, FirebaseURL) => {
site.service('DisconnectNotifier', ($q, $window, FirebaseURL) => {
const firebase = new Firebase(`${FirebaseURL}/.info/connected`);
const defer = $q.defer();

firebase.on('value', (snap) => {
defer.notify(snap.val());
const val = snap.val();
defer.notify(val);
$window.onbeforeunload = val ? undefined : () => 'If you quit this app now, you may lose all unsynced data. Are you sure you want to do this?';
});

return defer.promise;
Expand Down

0 comments on commit a991b07

Please sign in to comment.