a bit of cleanup, better naming of the app cache

This commit is contained in:
or-else
2021-05-08 18:01:14 -07:00
parent 62259ab331
commit aa8d60cc1d
14 changed files with 428 additions and 418 deletions
+4 -9
View File
@@ -1,7 +1,7 @@
{ {
"name": "tinode-webapp", "name": "tinode-webapp",
"description": "Tinode messenger for the web", "description": "Tinode messenger for the web",
"version": "0.17.0", "version": "0.17.1-alpha1",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/tinode/example-react-js.git" "url": "https://github.com/tinode/example-react-js.git"
@@ -18,12 +18,6 @@
}, },
"browserslist": "> 0.5%, not IE 11", "browserslist": "> 0.5%, not IE 11",
"files": [ "files": [
"src/index.js",
"src/config.js",
"src/views/*.jsx",
"src/widgets/*.jsx",
"src/lib/*.js",
"src/i18n/*.json",
"umd/index.prod.js", "umd/index.prod.js",
"umd/index.prod.js.map", "umd/index.prod.js.map",
"umd/index.dev.js", "umd/index.dev.js",
@@ -40,7 +34,8 @@
"index.html", "index.html",
"manifest.json", "manifest.json",
"service-worker.js", "service-worker.js",
"firebase-init.js" "firebase-init.js",
"version.js"
], ],
"keywords": [ "keywords": [
"chat", "chat",
@@ -72,7 +67,7 @@
"react": "^17.0.1", "react": "^17.0.1",
"react-dom": "^17.0.1", "react-dom": "^17.0.1",
"react-intl": "^5.12.5", "react-intl": "^5.12.5",
"tinode-sdk": "^0.17.0" "tinode-sdk": "^0.17.1-alpha1"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.13.8", "@babel/core": "^7.13.8",
+16 -11
View File
@@ -1,13 +1,18 @@
var fs = require('fs'); const fs = require('fs');
var version = require('../package.json').version; const version = require('../package.json').version;
fs.writeFile('./src/version.js', function writeVersion(fileName, useExport) {
'// This is a generated file. Don\'t edit.\n\n'+ fs.writeFile(fileName,
'export const PACKAGE_VERSION = "'+version+'";\n', '// This is a generated file. Don\'t edit.\n\n'+
{ flag: 'w' }, `${useExport ? 'export ' : ''}const PACKAGE_VERSION = "${version}";\n`,
function(err) { { flag: 'w' },
if (err) { (err) => {
return console.log(err); if (err) {
return console.log(err);
}
} }
} );
); }
writeVersion('./src/version.js', true);
writeVersion('./version.js', false);
+4 -4
View File
@@ -2,6 +2,7 @@
importScripts('https://cdn.jsdelivr.net/npm/firebase@8.2.9/firebase-app.js'); importScripts('https://cdn.jsdelivr.net/npm/firebase@8.2.9/firebase-app.js');
importScripts('https://cdn.jsdelivr.net/npm/firebase@8.2.9/firebase-messaging.js'); importScripts('https://cdn.jsdelivr.net/npm/firebase@8.2.9/firebase-messaging.js');
importScripts('firebase-init.js'); importScripts('firebase-init.js');
importScripts('version.js');
// Channel to notify the webapp. // Channel to notify the webapp.
const webAppChannel = new BroadcastChannel('tinode-sw'); const webAppChannel = new BroadcastChannel('tinode-sw');
@@ -132,18 +133,17 @@ self.addEventListener('fetch', event => {
return response; return response;
} }
if (event.request.url && (event.request.url.startsWith('http://') || event.request.url.startsWith('https://'))) { if (event.request.url && (event.request.url.startsWith('http://') || event.request.url.startsWith('https://'))) {
const cache = await caches.open(self.version); const cache = await caches.open(PACKAGE_VERSION);
await cache.put(event.request, response.clone()); await cache.put(event.request, response.clone());
} }
return response; return response;
})()); })());
}); });
// This code get the human language & app version from the webapp. // This code get the human language from the webapp.
// Locale is used for localization of strings, version for naming the cache. // Locale is used for localization of strings.
self.addEventListener('message', event => { self.addEventListener('message', event => {
const data = JSON.parse(event.data); const data = JSON.parse(event.data);
self.locale = data.locale || ''; self.locale = data.locale || '';
self.baseLocale = self.locale.toLowerCase().split(/[-_]/)[0]; self.baseLocale = self.locale.toLowerCase().split(/[-_]/)[0];
self.version = data.version || 'default';
}); });
+11 -10
View File
@@ -1,7 +1,7 @@
import { PACKAGE_VERSION } from './version.js'; import { PACKAGE_VERSION } from './version.js';
// Name of this application, used in the User-Agent. // Name of this application, used in the User-Agent.
export const APP_NAME = 'TinodeWeb/' + (PACKAGE_VERSION || '0.16'); export const APP_NAME = 'TinodeWeb/' + (PACKAGE_VERSION || '0.17');
// API key. Use https://github.com/tinode/chat/tree/master/keygen to generate your own // API key. Use https://github.com/tinode/chat/tree/master/keygen to generate your own
export const API_KEY = 'AQEAAAABAAD_rAp4DJh05a1HAwFT3A6K'; export const API_KEY = 'AQEAAAABAAD_rAp4DJh05a1HAwFT3A6K';
@@ -22,11 +22,11 @@ export const RECEIVED_DELAY = 500;
// Delay before sending a read notification, milliseconds. // Delay before sending a read notification, milliseconds.
export const READ_DELAY = 1000; export const READ_DELAY = 1000;
// The shortest allowed tag length. Matches the value on the server. // The default shortest allowed tag length. Matches the value on the server.
export const MIN_TAG_LENGTH = 2; export const MIN_TAG_LENGTH = 2;
// The greatest allowed tag length. Matches the value on the server. // The default greatest allowed tag length. Matches the value on the server.
export const MAX_TAG_LENGTH = 96; export const MAX_TAG_LENGTH = 96;
// The maximum number of tags allowed. Matches the value on the server. // The default maximum number of tags allowed. Matches the value on the server.
export const MAX_TAG_COUNT = 16; export const MAX_TAG_COUNT = 16;
// Access mode for P2P subscriptions initiated by the current user. // Access mode for P2P subscriptions initiated by the current user.
@@ -56,17 +56,18 @@ export const BROKEN_IMAGE_SIZE = 32;
export const MESSAGES_PAGE = 24; export const MESSAGES_PAGE = 24;
// Default maximum in-band (included directly into the message) attachment size which fits into // Default maximum in-band (included directly into the message) attachment size which fits into
// a message of 256K in size. The actual binary size of the attachment should be smaller due to // a message of 256K in size. Used when the server-provided value is unavailable. The actual
// base64 encoding expansion and some overhead, for instance 1024 bytes. // binary size of the attachment should be smaller due to base64 encoding expansion and some overhead,
// for instance 1024 bytes.
// Increase this limit to a greater value in production, if desired. Also increase // Increase this limit to a greater value in production, if desired. Also increase
// max_message_size in the server config. // max_message_size in the server config.
export const MAX_INBAND_ATTACHMENT_SIZE = 262144; export const MAX_INBAND_ATTACHMENT_SIZE = 262144;
// Absolute maximum attachment size to be used with the server = 8MB. Increase to // Default absolute maximum attachment size to be used with the server = 8MB.
// something like 100MB in production. // Used when the server-provided value is unavailable. Increase to something like 100MB in production.
export const MAX_EXTERN_ATTACHMENT_SIZE = 1 << 23; export const MAX_EXTERN_ATTACHMENT_SIZE = 1 << 23;
// Maximum allowed linear dimension of an inline image in pixels. Larer images will be shrunk // Maximum allowed linear dimension (pixels) of an image sent inline. Larger images will be shrunk
// to make the larger dimension fit under this size. You may want to adjust it to 1600 or // to make the larger dimension fit under this size. You may want to adjust it to 1600 or
// 2400 for production. // 2400 for production.
export const MAX_IMAGE_DIM = 1024; export const MAX_IMAGE_DIM = 1024;
@@ -85,7 +86,7 @@ export const MAX_TITLE_LENGTH = 60;
export const MESSAGE_PREVIEW_LENGTH = 80; export const MESSAGE_PREVIEW_LENGTH = 80;
// Link for "Contact Us". // Link for "Contact Us".
export const LINK_CONTACT_US = 'email:info@tinode.co'; export const LINK_CONTACT_US = 'email:support@tinode.co';
// Link to Privacy Policy. // Link to Privacy Policy.
export const LINK_PRIVACY_POLICY = 'https://tinode.co/privacy.html'; export const LINK_PRIVACY_POLICY = 'https://tinode.co/privacy.html';
+1 -1
View File
@@ -1,3 +1,3 @@
// This is a generated file. Don't edit. // This is a generated file. Don't edit.
export const PACKAGE_VERSION = "0.17.0"; export const PACKAGE_VERSION = "0.17.1-alpha1";
+6 -7
View File
@@ -36,16 +36,15 @@ export default class SettingsView extends React.PureComponent {
render() { render() {
const names = {def: "default", ws: "websocket", lp: "long polling"}; const names = {def: "default", ws: "websocket", lp: "long polling"};
var transportOptions = []; const transportOptions = [];
var instance = this; ['def', 'ws', 'lp'].map((item) => {
['def', 'ws', 'lp'].map(function(item) { const id = 'transport-' + item;
var id = 'transport-' + item; const name = names[item];
var name = names[item];
transportOptions.push( transportOptions.push(
<li key={item}> <li key={item}>
<input type="radio" id={id} name="transport-select" value={item} <input type="radio" id={id} name="transport-select" value={item}
checked={instance.state.transport === item} checked={this.state.transport === item}
onChange={instance.handleTransportSelected} /> onChange={this.handleTransportSelected} />
<label htmlFor={id}>{name}</label> <label htmlFor={id}>{name}</label>
</li> </li>
); );
+2 -2
View File
@@ -324,8 +324,8 @@ class TinodeWeb extends React.Component {
this.checkForAppUpdate(reg); this.checkForAppUpdate(reg);
this.fbPush.useServiceWorker(reg); this.fbPush.useServiceWorker(reg);
reg.active.postMessage(JSON.stringify({locale: locale, version: PACKAGE_VERSION})); reg.active.postMessage(JSON.stringify({locale: locale, version: PACKAGE_VERSION}));
// Google could not be bothered to mention that
// onTokenRefresh is never called. // Google could not be bothered to mention that onTokenRefresh is never called.
this.fbPush.onTokenRefresh(() => { this.fbPush.onTokenRefresh(() => {
this.requestPushToken(); this.requestPushToken();
}); });
+4
View File
@@ -157,6 +157,10 @@ function draftyFormatter(style, data, values, key) {
el = React.Fragment; el = React.Fragment;
break; break;
case 'EX': case 'EX':
if (data && data.mime == 'application/json') {
// Ignore JSON attachments: they are form response payloads.
return null;
}
el = React.Fragment; el = React.Fragment;
values = [<i key="ex" className="material-icons">attachment</i>, formatMessage(messages.drafty_attachment)]; values = [<i key="ex" className="material-icons">attachment</i>, formatMessage(messages.drafty_attachment)];
break; break;
+13 -10
View File
@@ -43,7 +43,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export */ }); /* harmony export */ });
/* harmony import */ var _version_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./version.js */ "./src/version.js"); /* harmony import */ var _version_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./version.js */ "./src/version.js");
const APP_NAME = 'TinodeWeb/' + (_version_js__WEBPACK_IMPORTED_MODULE_0__.PACKAGE_VERSION || '0.16'); const APP_NAME = 'TinodeWeb/' + (_version_js__WEBPACK_IMPORTED_MODULE_0__.PACKAGE_VERSION || '0.17');
const API_KEY = 'AQEAAAABAAD_rAp4DJh05a1HAwFT3A6K'; const API_KEY = 'AQEAAAABAAD_rAp4DJh05a1HAwFT3A6K';
const KNOWN_HOSTS = { const KNOWN_HOSTS = {
hosted: 'web.tinode.co', hosted: 'web.tinode.co',
@@ -73,7 +73,7 @@ const IMAGE_PREVIEW_DIM = 64;
const MAX_ONLINE_IN_TOPIC = 4; const MAX_ONLINE_IN_TOPIC = 4;
const MAX_TITLE_LENGTH = 60; const MAX_TITLE_LENGTH = 60;
const MESSAGE_PREVIEW_LENGTH = 80; const MESSAGE_PREVIEW_LENGTH = 80;
const LINK_CONTACT_US = 'email:info@tinode.co'; const LINK_CONTACT_US = 'email:support@tinode.co';
const LINK_PRIVACY_POLICY = 'https://tinode.co/privacy.html'; const LINK_PRIVACY_POLICY = 'https://tinode.co/privacy.html';
const LINK_TERMS_OF_SERVICE = 'https://tinode.co/terms.html'; const LINK_TERMS_OF_SERVICE = 'https://tinode.co/terms.html';
@@ -702,7 +702,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "PACKAGE_VERSION": function() { return /* binding */ PACKAGE_VERSION; } /* harmony export */ "PACKAGE_VERSION": function() { return /* binding */ PACKAGE_VERSION; }
/* harmony export */ }); /* harmony export */ });
const PACKAGE_VERSION = "0.17.0"; const PACKAGE_VERSION = "0.17.1-alpha1";
/***/ }), /***/ }),
@@ -4396,11 +4396,10 @@ class SettingsView extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureCom
ws: "websocket", ws: "websocket",
lp: "long polling" lp: "long polling"
}; };
var transportOptions = []; const transportOptions = [];
var instance = this; ['def', 'ws', 'lp'].map(item => {
['def', 'ws', 'lp'].map(function (item) { const id = 'transport-' + item;
var id = 'transport-' + item; const name = names[item];
var name = names[item];
transportOptions.push(react__WEBPACK_IMPORTED_MODULE_0___default().createElement("li", { transportOptions.push(react__WEBPACK_IMPORTED_MODULE_0___default().createElement("li", {
key: item key: item
}, react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", { }, react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", {
@@ -4408,8 +4407,8 @@ class SettingsView extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureCom
id: id, id: id,
name: "transport-select", name: "transport-select",
value: item, value: item,
checked: instance.state.transport === item, checked: this.state.transport === item,
onChange: instance.handleTransportSelected onChange: this.handleTransportSelected
}), react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", { }), react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
htmlFor: id htmlFor: id
}, name))); }, name)));
@@ -7938,6 +7937,10 @@ function draftyFormatter(style, data, values, key) {
break; break;
case 'EX': case 'EX':
if (data && data.mime == 'application/json') {
return null;
}
el = (react__WEBPACK_IMPORTED_MODULE_0___default().Fragment); el = (react__WEBPACK_IMPORTED_MODULE_0___default().Fragment);
values = [react__WEBPACK_IMPORTED_MODULE_0___default().createElement("i", { values = [react__WEBPACK_IMPORTED_MODULE_0___default().createElement("i", {
key: "ex", key: "ex",
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+363 -360
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long