Field: make id optional, generate one if not provided

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2020-03-29 22:59:15 +01:00
parent 5ea4623d26
commit ec9316c803
4 changed files with 35 additions and 10 deletions

View File

@ -14,9 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import {ReactElement} from "react";
interface Window { interface Window {
Olm: { Olm: {
init: () => Promise<void>; init: () => Promise<void>;
}; };
mxSendRageshake: (text: string, withLogs?: boolean) => void; mxSendRageshake: (text: string, withLogs?: boolean) => void;
matrixChat: ReactElement;
} }

View File

@ -24,8 +24,7 @@ limitations under the License.
require('gfm.css/gfm.css'); require('gfm.css/gfm.css');
require('highlight.js/styles/github.css'); require('highlight.js/styles/github.css');
// These are things that can run before the skin loads - be careful not to reference the react-sdk though.
import './rageshakesetup';
import './modernizr'; import './modernizr';
// load service worker if available on this platform // load service worker if available on this platform
@ -33,13 +32,28 @@ if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('sw.js'); 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 async function start() {
// the SDK until we have to in imports. const { initRageshake, loadSkin } = await import(
import {loadSkin} from "./init"; /* webpackChunkName: "init" */
loadSkin().then(() => { /* webpackPreload: true */
"./init");
// These are things that can run before the skin loads - be careful not to reference the react-sdk though.
await initRageshake();
// 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.
await loadSkin();
// Finally, load the app. All of the other react-sdk imports are in this file which causes the skinner to // Finally, load the app. All of the other react-sdk imports are in this file which causes the skinner to
// run on the components. We use `require` here to make sure webpack doesn't optimize this into an async // run on the components. We use `require` here to make sure webpack doesn't optimize this into an async
// import and thus running before the skin can load. // import and thus running before the skin can load.
require("./app").loadApp(); const { loadApp } = await import(
}); /* webpackChunkName: "app" */
/* webpackPreload: true */
"./app");
loadApp();
}
start();

View File

@ -121,3 +121,9 @@ export async function loadTheme() {
// as quickly as we possibly can, set a default theme... // as quickly as we possibly can, set a default theme...
await setTheme(); await setTheme();
} }
import rageshakeProm from "./rageshakesetup";
export async function initRageshake() {
return rageshakeProm;
}

View File

@ -31,7 +31,8 @@ import SdkConfig from "matrix-react-sdk/src/SdkConfig";
import sendBugReport from "matrix-react-sdk/src/rageshake/submit-rageshake"; import sendBugReport from "matrix-react-sdk/src/rageshake/submit-rageshake";
function initRageshake() { function initRageshake() {
rageshake.init().then(() => { const prom = rageshake.init();
prom.then(() => {
console.log("Initialised rageshake."); console.log("Initialised rageshake.");
console.log("To fix line numbers in Chrome: " + console.log("To fix line numbers in Chrome: " +
"Meatball menu → Settings → Blackboxing → Add /rageshake\\.js$"); "Meatball menu → Settings → Blackboxing → Add /rageshake\\.js$");
@ -46,9 +47,10 @@ function initRageshake() {
}, (err) => { }, (err) => {
console.error("Failed to initialise rageshake: " + err); console.error("Failed to initialise rageshake: " + err);
}); });
return prom;
} }
initRageshake(); export default initRageshake();
window.mxSendRageshake = function(text: string, withLogs?: boolean) { window.mxSendRageshake = function(text: string, withLogs?: boolean) {
if (withLogs === undefined) withLogs = true; if (withLogs === undefined) withLogs = true;