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.
*/
import {ReactElement} from "react";
interface Window {
Olm: {
init: () => Promise<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('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';
// load service worker if available on this platform
@ -33,13 +32,28 @@ 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.
import {loadSkin} from "./init";
loadSkin().then(() => {
async function start() {
const { initRageshake, loadSkin } = await import(
/* webpackChunkName: "init" */
/* 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
// 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.
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...
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";
function initRageshake() {
rageshake.init().then(() => {
const prom = rageshake.init();
prom.then(() => {
console.log("Initialised rageshake.");
console.log("To fix line numbers in Chrome: " +
"Meatball menu → Settings → Blackboxing → Add /rageshake\\.js$");
@ -46,9 +47,10 @@ function initRageshake() {
}, (err) => {
console.error("Failed to initialise rageshake: " + err);
});
return prom;
}
initRageshake();
export default initRageshake();
window.mxSendRageshake = function(text: string, withLogs?: boolean) {
if (withLogs === undefined) withLogs = true;