add comment to update Firebase in service worker
This commit is contained in:
@@ -33,9 +33,6 @@
|
||||
<script crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/react-dom@17/umd/react-dom.development.js"></script>
|
||||
<!-- React-Intl for translations -->
|
||||
<script crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/react-intl@5/react-intl.iife.js"></script>
|
||||
<!-- Firebase for push notifications -->
|
||||
<script crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/firebase@9/firebase-app.js"></script>
|
||||
<script crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/firebase@9/firebase-messaging.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
<script crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/react@17.0.2/umd/react.production.min.js"></script>
|
||||
<script crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/react-dom@17.0.2/umd/react-dom.production.min.js"></script>
|
||||
<script crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/react-intl@5.20.7/react-intl.iife.min.js"></script>
|
||||
<script crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/firebase@9.6.7/firebase-app.js"></script>
|
||||
<script crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/firebase@9.6.7/firebase-messaging.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<noscript><div id="noscript-message"><div id="noscript-title">Javascript support is required.</div>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Must be located at the root.
|
||||
// FIXME: update Firebase version.
|
||||
importScripts('https://cdn.jsdelivr.net/npm/firebase@8.10.1/firebase-app.js');
|
||||
importScripts('https://cdn.jsdelivr.net/npm/firebase@8.10.1/firebase-messaging.js');
|
||||
importScripts('firebase-init.js');
|
||||
|
||||
@@ -164,9 +164,11 @@ class TinodeWeb extends React.Component {
|
||||
// "On" is the default, so saving the "off" state.
|
||||
messageSounds: !settings.messageSoundsOff,
|
||||
incognitoMode: false,
|
||||
// Persistent request to enable alerts.
|
||||
desktopAlerts: persist && !!settings.desktopAlerts,
|
||||
// Enable / disable checkbox.
|
||||
desktopAlertsEnabled: (isSecureConnection() || isLocalHost()) &&
|
||||
(typeof firebase != 'undefined') && (typeof navigator != 'undefined') &&
|
||||
(typeof firebaseInitApp != 'undefined') && (typeof navigator != 'undefined') &&
|
||||
(typeof FIREBASE_INIT != 'undefined'),
|
||||
firebaseToken: persist ? LocalStorageUtil.getObject('firebase-token') : null,
|
||||
|
||||
@@ -257,11 +259,7 @@ class TinodeWeb extends React.Component {
|
||||
if (this.state.desktopAlertsEnabled) {
|
||||
this.initFCMessaging().then(() => {
|
||||
if (this.state.desktopAlerts) {
|
||||
if (!this.state.firebaseToken) {
|
||||
this.toggleFCMToken(true);
|
||||
} else {
|
||||
this.tinode.setDeviceToken(this.state.firebaseToken);
|
||||
}
|
||||
this.tinode.setDeviceToken(this.state.firebaseToken);
|
||||
}
|
||||
}).catch(() => {
|
||||
// do nothing: handled earlier.
|
||||
@@ -330,7 +328,8 @@ class TinodeWeb extends React.Component {
|
||||
const onError = (msg, err) => {
|
||||
console.error(msg, err);
|
||||
this.handleError(formatMessage(messages.push_init_failed), 'err');
|
||||
this.setState({desktopAlertsEnabled: false});
|
||||
this.setState({desktopAlertsEnabled: false, firebaseToken: null});
|
||||
LocalStorageUtil.updateObject('settings', {desktopAlerts: false});
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -1141,10 +1140,7 @@ class TinodeWeb extends React.Component {
|
||||
if (enabled) {
|
||||
this.setState({desktopAlerts: null});
|
||||
if (!this.state.firebaseToken) {
|
||||
this.initFCMessaging().catch(() => {
|
||||
this.setState({desktopAlerts: false, firebaseToken: null});
|
||||
LocalStorageUtil.updateObject('settings', {desktopAlerts: false});
|
||||
});
|
||||
this.initFCMessaging();
|
||||
} else {
|
||||
this.setState({desktopAlerts: true});
|
||||
if (LocalStorageUtil.getObject('keep-logged-in')) {
|
||||
|
||||
+6170
-35
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2
-4
@@ -52,8 +52,8 @@ module.exports = (env, argv) => {
|
||||
]
|
||||
},
|
||||
performance: {
|
||||
maxEntrypointSize: 294912,
|
||||
maxAssetSize: 294912
|
||||
maxEntrypointSize: 320000,
|
||||
maxAssetSize: 320000
|
||||
},
|
||||
plugins: [
|
||||
new CopyPlugin({
|
||||
@@ -66,8 +66,6 @@ module.exports = (env, argv) => {
|
||||
'react': 'React',
|
||||
'react-dom': 'ReactDOM',
|
||||
'react-intl': 'ReactIntl',
|
||||
'firebase/app': 'firebase',
|
||||
'firebase/messaging': ['firebase', 'messaging'],
|
||||
'tinode-sdk': 'Tinode',
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user