Merge branches 'develop' and 't3chguy/tooltip_accessible_button' of github.com:matrix-org/matrix-react-sdk into t3chguy/tooltip_accessible_button
commit
01a4a69787
|
@ -34,6 +34,26 @@ import WidgetUtils from "./utils/WidgetUtils";
|
||||||
import {textToHtmlRainbow} from "./utils/colour";
|
import {textToHtmlRainbow} from "./utils/colour";
|
||||||
import Promise from "bluebird";
|
import Promise from "bluebird";
|
||||||
|
|
||||||
|
const singleMxcUpload = async () => {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const fileSelector = document.createElement('input');
|
||||||
|
fileSelector.setAttribute('type', 'file');
|
||||||
|
fileSelector.onchange = (ev) => {
|
||||||
|
const file = ev.target.files[0];
|
||||||
|
|
||||||
|
const UploadConfirmDialog = sdk.getComponent("dialogs.UploadConfirmDialog");
|
||||||
|
Modal.createTrackedDialog('Upload Files confirmation', '', UploadConfirmDialog, {
|
||||||
|
file,
|
||||||
|
onFinished: (shouldContinue) => {
|
||||||
|
resolve(shouldContinue ? MatrixClientPeg.get().uploadContent(file) : null);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
fileSelector.click();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
class Command {
|
class Command {
|
||||||
constructor({name, args='', description, runFn, hideCompletionAfterSpace=false}) {
|
constructor({name, args='', description, runFn, hideCompletionAfterSpace=false}) {
|
||||||
this.command = '/' + name;
|
this.command = '/' + name;
|
||||||
|
@ -222,26 +242,11 @@ export const CommandMap = {
|
||||||
|
|
||||||
let promise = Promise.resolve(args);
|
let promise = Promise.resolve(args);
|
||||||
if (!args) {
|
if (!args) {
|
||||||
promise = new Promise((resolve) => {
|
promise = singleMxcUpload();
|
||||||
const fileSelector = document.createElement('input');
|
|
||||||
fileSelector.setAttribute('type', 'file');
|
|
||||||
fileSelector.onchange = (ev) => {
|
|
||||||
const file = ev.target.files[0];
|
|
||||||
|
|
||||||
const UploadConfirmDialog = sdk.getComponent("dialogs.UploadConfirmDialog");
|
|
||||||
Modal.createTrackedDialog('Upload Files confirmation', '', UploadConfirmDialog, {
|
|
||||||
file,
|
|
||||||
onFinished: (shouldContinue) => {
|
|
||||||
if (shouldContinue) resolve(cli.uploadContent(file));
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
fileSelector.click();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return success(promise.then((url) => {
|
return success(promise.then((url) => {
|
||||||
|
if (!url) return;
|
||||||
const ev = room.currentState.getStateEvents('m.room.member', userId);
|
const ev = room.currentState.getStateEvents('m.room.member', userId);
|
||||||
const content = {
|
const content = {
|
||||||
...ev ? ev.getContent() : { membership: 'join' },
|
...ev ? ev.getContent() : { membership: 'join' },
|
||||||
|
@ -252,6 +257,23 @@ export const CommandMap = {
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
myavatar: new Command({
|
||||||
|
name: 'myavatar',
|
||||||
|
args: '[<mxc_url>]',
|
||||||
|
description: _td('Changes your avatar in all rooms'),
|
||||||
|
runFn: function(roomId, args) {
|
||||||
|
let promise = Promise.resolve(args);
|
||||||
|
if (!args) {
|
||||||
|
promise = singleMxcUpload();
|
||||||
|
}
|
||||||
|
|
||||||
|
return success(promise.then((url) => {
|
||||||
|
if (!url) return;
|
||||||
|
return MatrixClientPeg.get().setAvatarUrl(url);
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
tint: new Command({
|
tint: new Command({
|
||||||
name: 'tint',
|
name: 'tint',
|
||||||
args: '<color1> [<color2>]',
|
args: '<color1> [<color2>]',
|
||||||
|
|
Loading…
Reference in New Issue