diff --git a/.gitignore b/.gitignore
index d9c993a..8f84f22 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,6 +36,8 @@ bundle.min.js
adminBundle.js
adminBundle.min.js
worker.js
+chatWorker.js
+chatWorker.min.js
node
src/main/javascript/node/
dist
diff --git a/Gruntfile.js b/Gruntfile.js
index cb1b80f..560af3b 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -13,8 +13,8 @@ module.exports = function (grunt) {
dest: "src/main/resources/static/js/bundle.min.js",
},
chat_worker: {
- src: "src/main/resources/static/js/worker.js",
- dest: "src/main/resources/static/js/worker.js",
+ src: "src/main/resources/static/js/chatWorker.js",
+ dest: "src/main/resources/static/js/chatWorker.min.js",
},
admin_bundle: {
src: "src/main/resources/static/js/adminBundle.js",
@@ -22,24 +22,26 @@ module.exports = function (grunt) {
},
},
banner: dedent(`
+ /*
* -----------------------------------------
* @date <%= grunt.template.today("yyyy-mm-dd") %>
* @project Chatto
* @author nova
* @license GPL
* -----------------------------------------
+ */
`),
usebanner: {
dist: {
options: {
position: "top",
- banner: "/*! \n<%= banner %> */ ",
+ banner: "<%= banner %>",
},
files: {
src: [
"src/main/resources/static/js/bundle.min.js",
"src/main/resources/static/js/adminBundle.min.js",
- "src/main/resources/static/js/worker.js",
+ "src/main/resources/static/js/chatWorker.min.js",
],
},
},
@@ -47,7 +49,7 @@ module.exports = function (grunt) {
browserify: {
chat_worker_dev: {
src: "src/main/frontend/workers/encryption-worker/main.ts",
- dest: "src/main/resources/static/js/worker.js",
+ dest: "src/main/resources/static/js/chatWorker.js",
options: {
browserifyOptions: {
debug: true,
@@ -75,7 +77,7 @@ module.exports = function (grunt) {
},
chat_worker_prod: {
src: "src/main/frontend/workers/encryption-worker/main.ts",
- dest: "src/main/resources/static/js/worker.js",
+ dest: "src/main/resources/static/js/chatWorker.js",
},
admin_bundle_dev: {
src: "src/main/frontend/admin/main.ts",
diff --git a/src/main/frontend/common/service/EncryptionServiceFactory.ts b/src/main/frontend/common/service/EncryptionServiceFactory.ts
index 4c10083..6e02c23 100644
--- a/src/main/frontend/common/service/EncryptionServiceFactory.ts
+++ b/src/main/frontend/common/service/EncryptionServiceFactory.ts
@@ -4,9 +4,13 @@ import { SJCLEncryptionService } from "./SJCLEncryptionService";
import PromiseWorker from "promise-worker";
export class EncryptionServiceFactory {
- private static readonly _worker = new Worker('/js/worker.js');
- private static readonly _promiseWorker = new PromiseWorker(EncryptionServiceFactory._worker);
- public static getEncryptionService(): EncryptionService {
- return new SJCLEncryptionService(this._promiseWorker)
- }
-}
\ No newline at end of file
+ private static readonly _worker = new Worker(
+ localStorage.getItem("CHAT_WORKER_BUNDLE") || "chat-worker-error.js"
+ );
+ private static readonly _promiseWorker = new PromiseWorker(
+ EncryptionServiceFactory._worker
+ );
+ public static getEncryptionService(): EncryptionService {
+ return new SJCLEncryptionService(this._promiseWorker);
+ }
+}
diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties
index 68a8386..e79ad14 100644
--- a/src/main/resources/application-prod.properties
+++ b/src/main/resources/application-prod.properties
@@ -7,4 +7,5 @@ spring.http.log-request-details=false
logging.level.org.springframework.cache = INFO
chat-bundle=bundle.min.js
admin-bundle=adminBundle.min.js
+chat-worker-bundle=chatWorker.min.js
chatto.frontend.log-level=INFO
\ No newline at end of file
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index ddb0a43..fd9545a 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -29,6 +29,7 @@ logging.level.org.springframework.cache=DEBUG
chatto.token.timeout-duration=30
chat-bundle=bundle.js
admin-bundle=adminBundle.js
+chat-worker-bundle=chatWorker.js
# spring.devtools.add-properties=false
chatto.frontend.log-level=TRACE
chatto.frontend.chat-page-size=9
\ No newline at end of file
diff --git a/src/main/resources/templates/chat.html b/src/main/resources/templates/chat.html
index 3c652e8..39f1589 100644
--- a/src/main/resources/templates/chat.html
+++ b/src/main/resources/templates/chat.html
@@ -13,6 +13,8 @@
+
diff --git a/src/main/resources/templates/fragments/head.html b/src/main/resources/templates/fragments/head.html
index e8399bf..1d2c0e0 100644
--- a/src/main/resources/templates/fragments/head.html
+++ b/src/main/resources/templates/fragments/head.html
@@ -64,6 +64,9 @@
let loglevel = /*[[${@environment.getProperty('chatto.frontend.log-level')}]]*/ "DEBUG";
window.log.setLevel(loglevel)
+ let chatWorkerBundle = /*[[${@environment.getProperty('chat-worker-bundle')}]]*/ "chatWorker.js";
+ localStorage.setItem('CHAT_WORKER_BUNDLE', "/js/" + chatWorkerBundle)
+
let chatPageSize = /*[[${@environment.getProperty('chatto.frontend.chat-page-size')}]]*/ 9;
localStorage.setItem("CHAT_PAGE_SIZE", chatPageSize);