diff --git a/src/vector/app.js b/src/vector/app.js index 458d061bc2..da46dffd76 100644 --- a/src/vector/app.js +++ b/src/vector/app.js @@ -173,14 +173,17 @@ function onTokenLoginCompleted() { } export async function loadApp() { - if (window.vector_indexeddb_worker_script === undefined) { + // XXX: the way we pass the path to the worker script from webpack via html in body's dataset is a hack + // but alternatives seem to require changing the interface to passing Workers to js-sdk + const vectorIndexeddbWorkerScript = document.body.dataset.vectorIndexeddbWorkerScript; + if (!vectorIndexeddbWorkerScript) { // If this is missing, something has probably gone wrong with // the bundling. The js-sdk will just fall back to accessing // indexeddb directly with no worker script, but we want to // make sure the indexeddb script is present, so fail hard. throw new Error("Missing indexeddb worker script!"); } - MatrixClientPeg.setIndexedDbWorkerScript(window.vector_indexeddb_worker_script); + MatrixClientPeg.setIndexedDbWorkerScript(vectorIndexeddbWorkerScript); CallHandler.setConferenceHandler(VectorConferenceHandler); window.addEventListener('hashchange', onHashChange); diff --git a/src/vector/index.html b/src/vector/index.html index fc880633e8..3fc2f8ca90 100644 --- a/src/vector/index.html +++ b/src/vector/index.html @@ -22,6 +22,21 @@ + <% for (var i=0; i < htmlWebpackPlugin.files.css.length; i++) { var file = htmlWebpackPlugin.files.css[i]; var match = file.match(/^bundles\/.*?\/theme-(.*)\.css$/); @@ -34,18 +49,10 @@ <% } } %> - +
- - diff --git a/src/vector/index.js b/src/vector/index.js index 278c62107f..3f34f2c1dc 100644 --- a/src/vector/index.js +++ b/src/vector/index.js @@ -29,6 +29,11 @@ require('highlight.js/styles/github.css'); import './rageshakesetup'; import './modernizr'; +// load service worker if available on this platform +if ('serviceWorker' in navigator) { + navigator.serviceWorker.register('sw.js'); +} + // Ensure the skin is the very first thing to load for the react-sdk. We don't even want to reference // the SDK until we have to in imports. console.log("Loading skin...");