Merge branch 'develop' into travis/feature/wellknown2
This commit is contained in:
commit
83737654ff
18 changed files with 538 additions and 137 deletions
|
@ -18,7 +18,12 @@ limitations under the License.
|
||||||
margin: 10px 0;
|
margin: 10px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mx_DevTools_RoomStateExplorer_button, .mx_DevTools_RoomStateExplorer_query {
|
.mx_DevTools_ServersInRoomList_button {
|
||||||
|
/* Set the cursor back to default as `.mx_Dialog button` sets it to pointer */
|
||||||
|
cursor: default !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_DevTools_RoomStateExplorer_button, .mx_DevTools_ServersInRoomList_button, .mx_DevTools_RoomStateExplorer_query {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ limitations under the License.
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
background-color: $reaction-row-button-bg-color;
|
background-color: $reaction-row-button-bg-color;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
border-color: $reaction-row-button-hover-border-color;
|
border-color: $reaction-row-button-hover-border-color;
|
||||||
|
|
|
@ -175,6 +175,8 @@ class MatrixClientPeg {
|
||||||
}
|
}
|
||||||
|
|
||||||
_createClient(creds: MatrixClientCreds) {
|
_createClient(creds: MatrixClientCreds) {
|
||||||
|
const aggregateRelations = SettingsStore.isFeatureEnabled("feature_reactions");
|
||||||
|
|
||||||
const opts = {
|
const opts = {
|
||||||
baseUrl: creds.homeserverUrl,
|
baseUrl: creds.homeserverUrl,
|
||||||
idBaseUrl: creds.identityServerUrl,
|
idBaseUrl: creds.identityServerUrl,
|
||||||
|
@ -183,7 +185,8 @@ class MatrixClientPeg {
|
||||||
deviceId: creds.deviceId,
|
deviceId: creds.deviceId,
|
||||||
timelineSupport: true,
|
timelineSupport: true,
|
||||||
forceTURN: !SettingsStore.getValue('webRtcAllowPeerToPeer', false),
|
forceTURN: !SettingsStore.getValue('webRtcAllowPeerToPeer', false),
|
||||||
verificationMethods: [verificationMethods.SAS]
|
verificationMethods: [verificationMethods.SAS],
|
||||||
|
unstableClientRelationAggregation: aggregateRelations,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.matrixClient = createMatrixClient(opts);
|
this.matrixClient = createMatrixClient(opts);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2015, 2016 OpenMarket Ltd
|
Copyright 2015, 2016 OpenMarket Ltd
|
||||||
Copyright 2018 New Vector Ltd
|
Copyright 2018 New Vector Ltd
|
||||||
|
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -30,6 +31,8 @@ import MultiInviter from './utils/MultiInviter';
|
||||||
import { linkifyAndSanitizeHtml } from './HtmlUtils';
|
import { linkifyAndSanitizeHtml } from './HtmlUtils';
|
||||||
import QuestionDialog from "./components/views/dialogs/QuestionDialog";
|
import QuestionDialog from "./components/views/dialogs/QuestionDialog";
|
||||||
import WidgetUtils from "./utils/WidgetUtils";
|
import WidgetUtils from "./utils/WidgetUtils";
|
||||||
|
import {textToHtmlRainbow} from "./utils/colour";
|
||||||
|
import Promise from "bluebird";
|
||||||
|
|
||||||
class Command {
|
class Command {
|
||||||
constructor({name, args='', description, runFn, hideCompletionAfterSpace=false}) {
|
constructor({name, args='', description, runFn, hideCompletionAfterSpace=false}) {
|
||||||
|
@ -190,8 +193,8 @@ export const CommandMap = {
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
roomnick: new Command({
|
myroomnick: new Command({
|
||||||
name: 'roomnick',
|
name: 'myroomnick',
|
||||||
args: '<display_name>',
|
args: '<display_name>',
|
||||||
description: _td('Changes your display nickname in the current room only'),
|
description: _td('Changes your display nickname in the current room only'),
|
||||||
runFn: function(roomId, args) {
|
runFn: function(roomId, args) {
|
||||||
|
@ -208,6 +211,47 @@ export const CommandMap = {
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
myroomavatar: new Command({
|
||||||
|
name: 'myroomavatar',
|
||||||
|
args: '[<mxc_url>]',
|
||||||
|
description: _td('Changes your avatar in this current room only'),
|
||||||
|
runFn: function(roomId, args) {
|
||||||
|
const cli = MatrixClientPeg.get();
|
||||||
|
const room = cli.getRoom(roomId);
|
||||||
|
const userId = cli.getUserId();
|
||||||
|
|
||||||
|
let promise = Promise.resolve(args);
|
||||||
|
if (!args) {
|
||||||
|
promise = 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) => {
|
||||||
|
if (shouldContinue) resolve(cli.uploadContent(file));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
fileSelector.click();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return success(promise.then((url) => {
|
||||||
|
const ev = room.currentState.getStateEvents('m.room.member', userId);
|
||||||
|
const content = {
|
||||||
|
...ev ? ev.getContent() : { membership: 'join' },
|
||||||
|
avatar_url: url,
|
||||||
|
};
|
||||||
|
return cli.sendStateEvent(roomId, 'm.room.member', content, userId);
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
tint: new Command({
|
tint: new Command({
|
||||||
name: 'tint',
|
name: 'tint',
|
||||||
args: '<color1> [<color2>]',
|
args: '<color1> [<color2>]',
|
||||||
|
@ -718,6 +762,26 @@ export const CommandMap = {
|
||||||
return success();
|
return success();
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
rainbow: new Command({
|
||||||
|
name: "rainbow",
|
||||||
|
description: _td("Sends the given message coloured as a rainbow"),
|
||||||
|
args: '<message>',
|
||||||
|
runFn: function(roomId, args) {
|
||||||
|
if (!args) return reject(this.getUserId());
|
||||||
|
return success(MatrixClientPeg.get().sendHtmlMessage(roomId, args, textToHtmlRainbow(args)));
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
|
rainbowme: new Command({
|
||||||
|
name: "rainbowme",
|
||||||
|
description: _td("Sends the given emote coloured as a rainbow"),
|
||||||
|
args: '<message>',
|
||||||
|
runFn: function(roomId, args) {
|
||||||
|
if (!args) return reject(this.getUserId());
|
||||||
|
return success(MatrixClientPeg.get().sendHtmlEmote(roomId, args, textToHtmlRainbow(args)));
|
||||||
|
},
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
/* eslint-enable babel/no-invalid-this */
|
/* eslint-enable babel/no-invalid-this */
|
||||||
|
|
||||||
|
@ -727,6 +791,7 @@ const aliases = {
|
||||||
j: "join",
|
j: "join",
|
||||||
newballsplease: "discardsession",
|
newballsplease: "discardsession",
|
||||||
goto: "join", // because it handles event permalinks magically
|
goto: "join", // because it handles event permalinks magically
|
||||||
|
roomnick: "myroomnick",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,9 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
// show timestamps always
|
// show timestamps always
|
||||||
alwaysShowTimestamps: PropTypes.bool,
|
alwaysShowTimestamps: PropTypes.bool,
|
||||||
|
|
||||||
|
// helper function to access relations for an event
|
||||||
|
getRelationsForEvent: PropTypes.func,
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillMount: function() {
|
componentWillMount: function() {
|
||||||
|
@ -513,8 +516,10 @@ module.exports = React.createClass({
|
||||||
ret.push(
|
ret.push(
|
||||||
<li key={eventId}
|
<li key={eventId}
|
||||||
ref={this._collectEventNode.bind(this, eventId)}
|
ref={this._collectEventNode.bind(this, eventId)}
|
||||||
data-scroll-tokens={scrollToken}>
|
data-scroll-tokens={scrollToken}
|
||||||
<EventTile mxEvent={mxEv} continuation={continuation}
|
>
|
||||||
|
<EventTile mxEvent={mxEv}
|
||||||
|
continuation={continuation}
|
||||||
isRedacted={mxEv.isRedacted()}
|
isRedacted={mxEv.isRedacted()}
|
||||||
onHeightChanged={this._onHeightChanged}
|
onHeightChanged={this._onHeightChanged}
|
||||||
readReceipts={readReceipts}
|
readReceipts={readReceipts}
|
||||||
|
@ -525,7 +530,10 @@ module.exports = React.createClass({
|
||||||
tileShape={this.props.tileShape}
|
tileShape={this.props.tileShape}
|
||||||
isTwelveHour={this.props.isTwelveHour}
|
isTwelveHour={this.props.isTwelveHour}
|
||||||
permalinkCreator={this.props.permalinkCreator}
|
permalinkCreator={this.props.permalinkCreator}
|
||||||
last={last} isSelectedEvent={highlight} />
|
last={last}
|
||||||
|
isSelectedEvent={highlight}
|
||||||
|
getRelationsForEvent={this.props.getRelationsForEvent}
|
||||||
|
/>
|
||||||
</li>,
|
</li>,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1168,6 +1168,10 @@ const TimelinePanel = React.createClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getRelationsForEvent(...args) {
|
||||||
|
return this.props.timelineSet.getRelationsForEvent(...args);
|
||||||
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
const MessagePanel = sdk.getComponent("structures.MessagePanel");
|
const MessagePanel = sdk.getComponent("structures.MessagePanel");
|
||||||
const Loader = sdk.getComponent("elements.Spinner");
|
const Loader = sdk.getComponent("elements.Spinner");
|
||||||
|
@ -1194,7 +1198,7 @@ const TimelinePanel = React.createClass({
|
||||||
if (this.state.events.length == 0 && !this.state.canBackPaginate && this.props.empty) {
|
if (this.state.events.length == 0 && !this.state.canBackPaginate && this.props.empty) {
|
||||||
return (
|
return (
|
||||||
<div className={this.props.className + " mx_RoomView_messageListWrapper"}>
|
<div className={this.props.className + " mx_RoomView_messageListWrapper"}>
|
||||||
<div className="mx_RoomView_empty">{ this.props.empty }</div>
|
<div className="mx_RoomView_empty">{this.props.empty}</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1239,6 +1243,7 @@ const TimelinePanel = React.createClass({
|
||||||
className={this.props.className}
|
className={this.props.className}
|
||||||
tileShape={this.props.tileShape}
|
tileShape={this.props.tileShape}
|
||||||
resizeNotifier={this.props.resizeNotifier}
|
resizeNotifier={this.props.resizeNotifier}
|
||||||
|
getRelationsForEvent={this.getRelationsForEvent}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2015, 2016 OpenMarket Ltd
|
Copyright 2015, 2016 OpenMarket Ltd
|
||||||
Copyright 2017 Vector Creations Ltd
|
Copyright 2017 Vector Creations Ltd
|
||||||
Copyright 2018 New Vector Ltd
|
Copyright 2018, 2019 New Vector Ltd
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -73,6 +73,7 @@ module.exports = React.createClass({
|
||||||
password: "",
|
password: "",
|
||||||
passwordConfirm: "",
|
passwordConfirm: "",
|
||||||
passwordComplexity: null,
|
passwordComplexity: null,
|
||||||
|
passwordSafe: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -147,7 +148,11 @@ module.exports = React.createClass({
|
||||||
if (!field) {
|
if (!field) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
field.validate({ allowEmpty: false });
|
// We must wait for these validations to finish before queueing
|
||||||
|
// up the setState below so our setState goes in the queue after
|
||||||
|
// all the setStates from these validate calls (that's how we
|
||||||
|
// know they've finished).
|
||||||
|
await field.validate({ allowEmpty: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validation and state updates are async, so we need to wait for them to complete
|
// Validation and state updates are async, so we need to wait for them to complete
|
||||||
|
@ -267,12 +272,23 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
const { scorePassword } = await import('../../../utils/PasswordScorer');
|
const { scorePassword } = await import('../../../utils/PasswordScorer');
|
||||||
const complexity = scorePassword(value);
|
const complexity = scorePassword(value);
|
||||||
|
const safe = complexity.score >= PASSWORD_MIN_SCORE;
|
||||||
|
const allowUnsafe = SdkConfig.get()["dangerously_allow_unsafe_and_insecure_passwords"];
|
||||||
this.setState({
|
this.setState({
|
||||||
passwordComplexity: complexity,
|
passwordComplexity: complexity,
|
||||||
|
passwordSafe: safe,
|
||||||
});
|
});
|
||||||
return complexity.score >= PASSWORD_MIN_SCORE;
|
return allowUnsafe || safe;
|
||||||
|
},
|
||||||
|
valid: function() {
|
||||||
|
// Unsafe passwords that are valid are only possible through a
|
||||||
|
// configuration flag. We'll print some helper text to signal
|
||||||
|
// to the user that their password is allowed, but unsafe.
|
||||||
|
if (!this.state.passwordSafe) {
|
||||||
|
return _t("Password is allowed, but unsafe");
|
||||||
|
}
|
||||||
|
return _t("Nice, strong password!");
|
||||||
},
|
},
|
||||||
valid: () => _t("Nice, strong password!"),
|
|
||||||
invalid: function() {
|
invalid: function() {
|
||||||
const complexity = this.state.passwordComplexity;
|
const complexity = this.state.passwordComplexity;
|
||||||
if (!complexity) {
|
if (!complexity) {
|
||||||
|
|
|
@ -551,11 +551,53 @@ class AccountDataExplorer extends DevtoolsComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ServersInRoomList extends DevtoolsComponent {
|
||||||
|
static getLabel() { return _t('View Servers in Room'); }
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
onBack: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
constructor(props, context) {
|
||||||
|
super(props, context);
|
||||||
|
|
||||||
|
const room = MatrixClientPeg.get().getRoom(this.context.roomId);
|
||||||
|
const servers = new Set();
|
||||||
|
room.currentState.getStateEvents("m.room.member").forEach(ev => servers.add(ev.getSender().split(":")[1]));
|
||||||
|
this.servers = Array.from(servers).map(s =>
|
||||||
|
<button key={s} className="mx_DevTools_ServersInRoomList_button">
|
||||||
|
{ s }
|
||||||
|
</button>);
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
query: '',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
onQuery = (query) => {
|
||||||
|
this.setState({ query });
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return <div>
|
||||||
|
<div className="mx_Dialog_content">
|
||||||
|
<FilteredList query={this.state.query} onChange={this.onQuery}>
|
||||||
|
{ this.servers }
|
||||||
|
</FilteredList>
|
||||||
|
</div>
|
||||||
|
<div className="mx_Dialog_buttons">
|
||||||
|
<button onClick={this.props.onBack}>{ _t('Back') }</button>
|
||||||
|
</div>
|
||||||
|
</div>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const Entries = [
|
const Entries = [
|
||||||
SendCustomEvent,
|
SendCustomEvent,
|
||||||
RoomStateExplorer,
|
RoomStateExplorer,
|
||||||
SendAccountData,
|
SendAccountData,
|
||||||
AccountDataExplorer,
|
AccountDataExplorer,
|
||||||
|
ServersInRoomList,
|
||||||
];
|
];
|
||||||
|
|
||||||
export default class DevtoolsDialog extends React.Component {
|
export default class DevtoolsDialog extends React.Component {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2019 New Vector Ltd
|
Copyright 2019 New Vector Ltd
|
||||||
|
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -24,6 +25,7 @@ import GeneralRoomSettingsTab from "../settings/tabs/room/GeneralRoomSettingsTab
|
||||||
import SecurityRoomSettingsTab from "../settings/tabs/room/SecurityRoomSettingsTab";
|
import SecurityRoomSettingsTab from "../settings/tabs/room/SecurityRoomSettingsTab";
|
||||||
import sdk from "../../../index";
|
import sdk from "../../../index";
|
||||||
import MatrixClientPeg from "../../../MatrixClientPeg";
|
import MatrixClientPeg from "../../../MatrixClientPeg";
|
||||||
|
import dis from "../../../dispatcher";
|
||||||
|
|
||||||
export default class RoomSettingsDialog extends React.Component {
|
export default class RoomSettingsDialog extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
@ -31,6 +33,22 @@ export default class RoomSettingsDialog extends React.Component {
|
||||||
onFinished: PropTypes.func.isRequired,
|
onFinished: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
componentWillMount() {
|
||||||
|
this._dispatcherRef = dis.register(this._onAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
dis.unregister(this._dispatcherRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
_onAction = (payload) => {
|
||||||
|
// When room changes below us, close the room settings
|
||||||
|
// whilst the modal is open this can only be triggered when someone hits Leave Room
|
||||||
|
if (payload.action === 'view_next_room') {
|
||||||
|
this.props.onFinished();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
_getTabs() {
|
_getTabs() {
|
||||||
const tabs = [];
|
const tabs = [];
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@ import { isContentActionable } from '../../../utils/EventUtils';
|
||||||
export default class MessageActionBar extends React.PureComponent {
|
export default class MessageActionBar extends React.PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
mxEvent: PropTypes.object.isRequired,
|
mxEvent: PropTypes.object.isRequired,
|
||||||
|
// The Relations model from the JS SDK for reactions to `mxEvent`
|
||||||
|
reactions: PropTypes.object,
|
||||||
permalinkCreator: PropTypes.object,
|
permalinkCreator: PropTypes.object,
|
||||||
getTile: PropTypes.func,
|
getTile: PropTypes.func,
|
||||||
getReplyThread: PropTypes.func,
|
getReplyThread: PropTypes.func,
|
||||||
|
@ -100,19 +102,11 @@ export default class MessageActionBar extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
const ReactionDimension = sdk.getComponent('messages.ReactionDimension');
|
const ReactionDimension = sdk.getComponent('messages.ReactionDimension');
|
||||||
const options = [
|
|
||||||
{
|
|
||||||
key: "agree",
|
|
||||||
content: "👍",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "disagree",
|
|
||||||
content: "👎",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
return <ReactionDimension
|
return <ReactionDimension
|
||||||
title={_t("Agree or Disagree")}
|
title={_t("Agree or Disagree")}
|
||||||
options={options}
|
options={["👍", "👎"]}
|
||||||
|
reactions={this.props.reactions}
|
||||||
|
mxEvent={this.props.mxEvent}
|
||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,19 +116,11 @@ export default class MessageActionBar extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
const ReactionDimension = sdk.getComponent('messages.ReactionDimension');
|
const ReactionDimension = sdk.getComponent('messages.ReactionDimension');
|
||||||
const options = [
|
|
||||||
{
|
|
||||||
key: "like",
|
|
||||||
content: "🙂",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "dislike",
|
|
||||||
content: "😔",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
return <ReactionDimension
|
return <ReactionDimension
|
||||||
title={_t("Like or Dislike")}
|
title={_t("Like or Dislike")}
|
||||||
options={options}
|
options={["🙂", "😔"]}
|
||||||
|
reactions={this.props.reactions}
|
||||||
|
mxEvent={this.props.mxEvent}
|
||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,49 +18,141 @@ import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
|
import MatrixClientPeg from '../../../MatrixClientPeg';
|
||||||
|
|
||||||
export default class ReactionDimension extends React.PureComponent {
|
export default class ReactionDimension extends React.PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
mxEvent: PropTypes.object.isRequired,
|
||||||
|
// Array of strings containing the emoji for each option
|
||||||
options: PropTypes.array.isRequired,
|
options: PropTypes.array.isRequired,
|
||||||
title: PropTypes.string,
|
title: PropTypes.string,
|
||||||
|
// The Relations model from the JS SDK for reactions
|
||||||
|
reactions: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = this.getSelection();
|
||||||
selected: null,
|
|
||||||
|
if (props.reactions) {
|
||||||
|
props.reactions.on("Relations.add", this.onReactionsChange);
|
||||||
|
props.reactions.on("Relations.redaction", this.onReactionsChange);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidUpdate(prevProps) {
|
||||||
|
if (prevProps.reactions !== this.props.reactions) {
|
||||||
|
this.props.reactions.on("Relations.add", this.onReactionsChange);
|
||||||
|
this.props.reactions.on("Relations.redaction", this.onReactionsChange);
|
||||||
|
this.onReactionsChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
if (this.props.reactions) {
|
||||||
|
this.props.reactions.removeListener(
|
||||||
|
"Relations.add",
|
||||||
|
this.onReactionsChange,
|
||||||
|
);
|
||||||
|
this.props.reactions.removeListener(
|
||||||
|
"Relations.redaction",
|
||||||
|
this.onReactionsChange,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onReactionsChange = () => {
|
||||||
|
this.setState(this.getSelection());
|
||||||
|
}
|
||||||
|
|
||||||
|
getSelection() {
|
||||||
|
const myReactions = this.getMyReactions();
|
||||||
|
if (!myReactions) {
|
||||||
|
return {
|
||||||
|
selectedOption: null,
|
||||||
|
selectedReactionEvent: null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
const { options } = this.props;
|
||||||
|
let selectedOption = null;
|
||||||
|
let selectedReactionEvent = null;
|
||||||
|
for (const option of options) {
|
||||||
|
const reactionForOption = myReactions.find(mxEvent => {
|
||||||
|
if (mxEvent.isRedacted()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return mxEvent.getContent()["m.relates_to"].key === option;
|
||||||
|
});
|
||||||
|
if (!reactionForOption) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (selectedOption) {
|
||||||
|
// If there are multiple selected values (only expected to occur via
|
||||||
|
// non-Riot clients), then act as if none are selected.
|
||||||
|
return {
|
||||||
|
selectedOption: null,
|
||||||
|
selectedReactionEvent: null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
selectedOption = option;
|
||||||
|
selectedReactionEvent = reactionForOption;
|
||||||
|
}
|
||||||
|
return { selectedOption, selectedReactionEvent };
|
||||||
|
}
|
||||||
|
|
||||||
|
getMyReactions() {
|
||||||
|
const reactions = this.props.reactions;
|
||||||
|
if (!reactions) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const userId = MatrixClientPeg.get().getUserId();
|
||||||
|
return reactions.getAnnotationsBySender()[userId];
|
||||||
|
}
|
||||||
|
|
||||||
onOptionClick = (ev) => {
|
onOptionClick = (ev) => {
|
||||||
const { key } = ev.target.dataset;
|
const { key } = ev.target.dataset;
|
||||||
this.toggleDimensionValue(key);
|
this.toggleDimension(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleDimensionValue(value) {
|
toggleDimension(key) {
|
||||||
const state = this.state.selected;
|
const { selectedOption, selectedReactionEvent } = this.state;
|
||||||
const newState = state !== value ? value : null;
|
const newSelectedOption = selectedOption !== key ? key : null;
|
||||||
this.setState({
|
this.setState({
|
||||||
selected: newState,
|
selectedOption: newSelectedOption,
|
||||||
});
|
});
|
||||||
// TODO: Send the reaction event
|
if (selectedReactionEvent) {
|
||||||
|
MatrixClientPeg.get().redactEvent(
|
||||||
|
this.props.mxEvent.getRoomId(),
|
||||||
|
selectedReactionEvent.getId(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (newSelectedOption) {
|
||||||
|
MatrixClientPeg.get().sendEvent(this.props.mxEvent.getRoomId(), "m.reaction", {
|
||||||
|
"m.relates_to": {
|
||||||
|
"rel_type": "m.annotation",
|
||||||
|
"event_id": this.props.mxEvent.getId(),
|
||||||
|
"key": newSelectedOption,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { selected } = this.state;
|
const { selectedOption } = this.state;
|
||||||
const { options } = this.props;
|
const { options } = this.props;
|
||||||
|
|
||||||
const items = options.map(option => {
|
const items = options.map(option => {
|
||||||
const disabled = selected && selected !== option.key;
|
const disabled = selectedOption && selectedOption !== option;
|
||||||
const classes = classNames({
|
const classes = classNames({
|
||||||
mx_ReactionDimension_disabled: disabled,
|
mx_ReactionDimension_disabled: disabled,
|
||||||
});
|
});
|
||||||
return <span key={option.key}
|
return <span key={option}
|
||||||
data-key={option.key}
|
data-key={option}
|
||||||
className={classes}
|
className={classes}
|
||||||
onClick={this.onOptionClick}
|
onClick={this.onOptionClick}
|
||||||
>
|
>
|
||||||
{option.content}
|
{option}
|
||||||
</span>;
|
</span>;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -19,42 +19,96 @@ import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import sdk from '../../../index';
|
import sdk from '../../../index';
|
||||||
import { isContentActionable } from '../../../utils/EventUtils';
|
import { isContentActionable } from '../../../utils/EventUtils';
|
||||||
|
import MatrixClientPeg from '../../../MatrixClientPeg';
|
||||||
// TODO: Actually load reactions from the timeline
|
|
||||||
// Since we don't yet load reactions, let's inject some dummy data for testing the UI
|
|
||||||
// only. The UI assumes these are already sorted into the order we want to present,
|
|
||||||
// presumably highest vote first.
|
|
||||||
const SAMPLE_REACTIONS = {
|
|
||||||
"👍": 4,
|
|
||||||
"👎": 2,
|
|
||||||
"🙂": 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default class ReactionsRow extends React.PureComponent {
|
export default class ReactionsRow extends React.PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
// The event we're displaying reactions for
|
// The event we're displaying reactions for
|
||||||
mxEvent: PropTypes.object.isRequired,
|
mxEvent: PropTypes.object.isRequired,
|
||||||
|
// The Relations model from the JS SDK for reactions to `mxEvent`
|
||||||
|
reactions: PropTypes.object,
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
|
||||||
|
if (props.reactions) {
|
||||||
|
props.reactions.on("Relations.add", this.onReactionsChange);
|
||||||
|
props.reactions.on("Relations.redaction", this.onReactionsChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
myReactions: this.getMyReactions(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidUpdate(prevProps) {
|
||||||
|
if (prevProps.reactions !== this.props.reactions) {
|
||||||
|
this.props.reactions.on("Relations.add", this.onReactionsChange);
|
||||||
|
this.props.reactions.on("Relations.redaction", this.onReactionsChange);
|
||||||
|
this.onReactionsChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
if (this.props.reactions) {
|
||||||
|
this.props.reactions.removeListener(
|
||||||
|
"Relations.add",
|
||||||
|
this.onReactionsChange,
|
||||||
|
);
|
||||||
|
this.props.reactions.removeListener(
|
||||||
|
"Relations.redaction",
|
||||||
|
this.onReactionsChange,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onReactionsChange = () => {
|
||||||
|
// TODO: Call `onHeightChanged` as needed
|
||||||
|
this.setState({
|
||||||
|
myReactions: this.getMyReactions(),
|
||||||
|
});
|
||||||
|
// Using `forceUpdate` for the moment, since we know the overall set of reactions
|
||||||
|
// has changed (this is triggered by events for that purpose only) and
|
||||||
|
// `PureComponent`s shallow state / props compare would otherwise filter this out.
|
||||||
|
this.forceUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
getMyReactions() {
|
||||||
|
const reactions = this.props.reactions;
|
||||||
|
if (!reactions) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const userId = MatrixClientPeg.get().getUserId();
|
||||||
|
return reactions.getAnnotationsBySender()[userId];
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { mxEvent } = this.props;
|
const { mxEvent, reactions } = this.props;
|
||||||
|
const { myReactions } = this.state;
|
||||||
|
|
||||||
if (!isContentActionable(mxEvent)) {
|
if (!reactions || !isContentActionable(mxEvent)) {
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const content = mxEvent.getContent();
|
|
||||||
// TODO: Remove this once we load real reactions
|
|
||||||
if (!content.body || content.body !== "reactions test") {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ReactionsRowButton = sdk.getComponent('messages.ReactionsRowButton');
|
const ReactionsRowButton = sdk.getComponent('messages.ReactionsRowButton');
|
||||||
const items = Object.entries(SAMPLE_REACTIONS).map(([content, count]) => {
|
const items = reactions.getSortedAnnotationsByKey().map(([content, events]) => {
|
||||||
|
const count = events.size;
|
||||||
|
if (!count) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const myReactionEvent = myReactions && myReactions.find(mxEvent => {
|
||||||
|
if (mxEvent.isRedacted()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return mxEvent.getContent()["m.relates_to"].key === content;
|
||||||
|
});
|
||||||
return <ReactionsRowButton
|
return <ReactionsRowButton
|
||||||
key={content}
|
key={content}
|
||||||
content={content}
|
content={content}
|
||||||
count={count}
|
count={count}
|
||||||
|
mxEvent={mxEvent}
|
||||||
|
myReactionEvent={myReactionEvent}
|
||||||
/>;
|
/>;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -18,48 +18,48 @@ import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
|
import MatrixClientPeg from '../../../MatrixClientPeg';
|
||||||
|
|
||||||
export default class ReactionsRowButton extends React.PureComponent {
|
export default class ReactionsRowButton extends React.PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
// The event we're displaying reactions for
|
||||||
|
mxEvent: PropTypes.object.isRequired,
|
||||||
content: PropTypes.string.isRequired,
|
content: PropTypes.string.isRequired,
|
||||||
count: PropTypes.number.isRequired,
|
count: PropTypes.number.isRequired,
|
||||||
}
|
// A possible Matrix event if the current user has voted for this type
|
||||||
|
myReactionEvent: PropTypes.object,
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
|
|
||||||
// TODO: This should be derived from actual reactions you may have sent
|
|
||||||
// once we have some API to read them.
|
|
||||||
this.state = {
|
|
||||||
selected: false,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onClick = (ev) => {
|
onClick = (ev) => {
|
||||||
const state = this.state.selected;
|
const { mxEvent, myReactionEvent, content } = this.props;
|
||||||
this.setState({
|
if (myReactionEvent) {
|
||||||
selected: !state,
|
MatrixClientPeg.get().redactEvent(
|
||||||
|
mxEvent.getRoomId(),
|
||||||
|
myReactionEvent.getId(),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
MatrixClientPeg.get().sendEvent(mxEvent.getRoomId(), "m.reaction", {
|
||||||
|
"m.relates_to": {
|
||||||
|
"rel_type": "m.annotation",
|
||||||
|
"event_id": mxEvent.getId(),
|
||||||
|
"key": content,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
// TODO: Send the reaction event
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { content, count } = this.props;
|
const { content, count, myReactionEvent } = this.props;
|
||||||
const { selected } = this.state;
|
|
||||||
|
|
||||||
const classes = classNames({
|
const classes = classNames({
|
||||||
mx_ReactionsRowButton: true,
|
mx_ReactionsRowButton: true,
|
||||||
mx_ReactionsRowButton_selected: selected,
|
mx_ReactionsRowButton_selected: !!myReactionEvent,
|
||||||
});
|
});
|
||||||
|
|
||||||
let adjustedCount = count;
|
|
||||||
if (selected) {
|
|
||||||
adjustedCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return <span className={classes}
|
return <span className={classes}
|
||||||
onClick={this.onClick}
|
onClick={this.onClick}
|
||||||
>
|
>
|
||||||
{content} {adjustedCount}
|
{content} {count}
|
||||||
</span>;
|
</span>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,6 +159,9 @@ module.exports = withMatrixClient(React.createClass({
|
||||||
|
|
||||||
// show twelve hour timestamps
|
// show twelve hour timestamps
|
||||||
isTwelveHour: PropTypes.bool,
|
isTwelveHour: PropTypes.bool,
|
||||||
|
|
||||||
|
// helper function to access relations for an event
|
||||||
|
getRelationsForEvent: PropTypes.func,
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
|
@ -179,6 +182,8 @@ module.exports = withMatrixClient(React.createClass({
|
||||||
verified: null,
|
verified: null,
|
||||||
// Whether onRequestKeysClick has been called since mounting.
|
// Whether onRequestKeysClick has been called since mounting.
|
||||||
previouslyRequestedKeys: false,
|
previouslyRequestedKeys: false,
|
||||||
|
// The Relations model from the JS SDK for reactions to `mxEvent`
|
||||||
|
reactions: this.getReactions(),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -190,9 +195,12 @@ module.exports = withMatrixClient(React.createClass({
|
||||||
|
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
this._suppressReadReceiptAnimation = false;
|
this._suppressReadReceiptAnimation = false;
|
||||||
this.props.matrixClient.on("deviceVerificationChanged",
|
const client = this.props.matrixClient;
|
||||||
this.onDeviceVerificationChanged);
|
client.on("deviceVerificationChanged", this.onDeviceVerificationChanged);
|
||||||
this.props.mxEvent.on("Event.decrypted", this._onDecrypted);
|
this.props.mxEvent.on("Event.decrypted", this._onDecrypted);
|
||||||
|
if (SettingsStore.isFeatureEnabled("feature_reactions")) {
|
||||||
|
this.props.mxEvent.on("Event.relationsCreated", this._onReactionsCreated);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillReceiveProps: function(nextProps) {
|
componentWillReceiveProps: function(nextProps) {
|
||||||
|
@ -215,6 +223,9 @@ module.exports = withMatrixClient(React.createClass({
|
||||||
const client = this.props.matrixClient;
|
const client = this.props.matrixClient;
|
||||||
client.removeListener("deviceVerificationChanged", this.onDeviceVerificationChanged);
|
client.removeListener("deviceVerificationChanged", this.onDeviceVerificationChanged);
|
||||||
this.props.mxEvent.removeListener("Event.decrypted", this._onDecrypted);
|
this.props.mxEvent.removeListener("Event.decrypted", this._onDecrypted);
|
||||||
|
if (SettingsStore.isFeatureEnabled("feature_reactions")) {
|
||||||
|
this.props.mxEvent.removeListener("Event.relationsCreated", this._onReactionsCreated);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/** called when the event is decrypted after we show it.
|
/** called when the event is decrypted after we show it.
|
||||||
|
@ -472,6 +483,27 @@ module.exports = withMatrixClient(React.createClass({
|
||||||
return this.refs.replyThread;
|
return this.refs.replyThread;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getReactions() {
|
||||||
|
if (
|
||||||
|
!this.props.getRelationsForEvent ||
|
||||||
|
!SettingsStore.isFeatureEnabled("feature_reactions")
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const eventId = this.props.mxEvent.getId();
|
||||||
|
return this.props.getRelationsForEvent(eventId, "m.annotation", "m.reaction");
|
||||||
|
},
|
||||||
|
|
||||||
|
_onReactionsCreated(relationType, eventType) {
|
||||||
|
if (relationType !== "m.annotation" || eventType !== "m.reaction") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.props.mxEvent.removeListener("Event.relationsCreated", this._onReactionsCreated);
|
||||||
|
this.setState({
|
||||||
|
reactions: this.getReactions(),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
const MessageTimestamp = sdk.getComponent('messages.MessageTimestamp');
|
const MessageTimestamp = sdk.getComponent('messages.MessageTimestamp');
|
||||||
const SenderProfile = sdk.getComponent('messages.SenderProfile');
|
const SenderProfile = sdk.getComponent('messages.SenderProfile');
|
||||||
|
@ -587,6 +619,7 @@ module.exports = withMatrixClient(React.createClass({
|
||||||
const MessageActionBar = sdk.getComponent('messages.MessageActionBar');
|
const MessageActionBar = sdk.getComponent('messages.MessageActionBar');
|
||||||
const actionBar = <MessageActionBar
|
const actionBar = <MessageActionBar
|
||||||
mxEvent={this.props.mxEvent}
|
mxEvent={this.props.mxEvent}
|
||||||
|
reactions={this.state.reactions}
|
||||||
permalinkCreator={this.props.permalinkCreator}
|
permalinkCreator={this.props.permalinkCreator}
|
||||||
getTile={this.getTile}
|
getTile={this.getTile}
|
||||||
getReplyThread={this.getReplyThread}
|
getReplyThread={this.getReplyThread}
|
||||||
|
@ -630,11 +663,12 @@ module.exports = withMatrixClient(React.createClass({
|
||||||
<ToolTipButton helpText={keyRequestHelpText} />
|
<ToolTipButton helpText={keyRequestHelpText} />
|
||||||
</div> : null;
|
</div> : null;
|
||||||
|
|
||||||
let reactions;
|
let reactionsRow;
|
||||||
if (SettingsStore.isFeatureEnabled("feature_reactions")) {
|
if (SettingsStore.isFeatureEnabled("feature_reactions")) {
|
||||||
const ReactionsRow = sdk.getComponent('messages.ReactionsRow');
|
const ReactionsRow = sdk.getComponent('messages.ReactionsRow');
|
||||||
reactions = <ReactionsRow
|
reactionsRow = <ReactionsRow
|
||||||
mxEvent={this.props.mxEvent}
|
mxEvent={this.props.mxEvent}
|
||||||
|
reactions={this.state.reactions}
|
||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -750,7 +784,7 @@ module.exports = withMatrixClient(React.createClass({
|
||||||
showUrlPreview={this.props.showUrlPreview}
|
showUrlPreview={this.props.showUrlPreview}
|
||||||
onHeightChanged={this.props.onHeightChanged} />
|
onHeightChanged={this.props.onHeightChanged} />
|
||||||
{ keyRequestInfo }
|
{ keyRequestInfo }
|
||||||
{ reactions }
|
{ reactionsRow }
|
||||||
{ actionBar }
|
{ actionBar }
|
||||||
</div>
|
</div>
|
||||||
{
|
{
|
||||||
|
|
|
@ -735,8 +735,8 @@ module.exports = withMatrixClient(React.createClass({
|
||||||
// we're only inviting one user.
|
// we're only inviting one user.
|
||||||
const inviter = new MultiInviter(roomId);
|
const inviter = new MultiInviter(roomId);
|
||||||
await inviter.invite([member.userId]).then(() => {
|
await inviter.invite([member.userId]).then(() => {
|
||||||
if (inviter.getCompletionState(userId) !== "invited")
|
if (inviter.getCompletionState(member.userId) !== "invited")
|
||||||
throw new Error(inviter.getErrorText(userId));
|
throw new Error(inviter.getErrorText(member.userId));
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const ErrorDialog = sdk.getComponent('dialogs.ErrorDialog');
|
const ErrorDialog = sdk.getComponent('dialogs.ErrorDialog');
|
||||||
|
|
|
@ -146,6 +146,7 @@
|
||||||
"Upgrade": "Upgrade",
|
"Upgrade": "Upgrade",
|
||||||
"Changes your display nickname": "Changes your display nickname",
|
"Changes your display nickname": "Changes your display nickname",
|
||||||
"Changes your display nickname in the current room only": "Changes your display nickname in the current room only",
|
"Changes your display nickname in the current room only": "Changes your display nickname in the current room only",
|
||||||
|
"Changes your avatar in this current room only": "Changes your avatar in this current room only",
|
||||||
"Changes colour scheme of current room": "Changes colour scheme of current room",
|
"Changes colour scheme of current room": "Changes colour scheme of current room",
|
||||||
"Gets or sets the room topic": "Gets or sets the room topic",
|
"Gets or sets the room topic": "Gets or sets the room topic",
|
||||||
"This room has no topic.": "This room has no topic.",
|
"This room has no topic.": "This room has no topic.",
|
||||||
|
@ -178,6 +179,8 @@
|
||||||
"The signing key you provided matches the signing key you received from %(userId)s's device %(deviceId)s. Device marked as verified.": "The signing key you provided matches the signing key you received from %(userId)s's device %(deviceId)s. Device marked as verified.",
|
"The signing key you provided matches the signing key you received from %(userId)s's device %(deviceId)s. Device marked as verified.": "The signing key you provided matches the signing key you received from %(userId)s's device %(deviceId)s. Device marked as verified.",
|
||||||
"Displays action": "Displays action",
|
"Displays action": "Displays action",
|
||||||
"Forces the current outbound group session in an encrypted room to be discarded": "Forces the current outbound group session in an encrypted room to be discarded",
|
"Forces the current outbound group session in an encrypted room to be discarded": "Forces the current outbound group session in an encrypted room to be discarded",
|
||||||
|
"Sends the given message coloured as a rainbow": "Sends the given message coloured as a rainbow",
|
||||||
|
"Sends the given emote coloured as a rainbow": "Sends the given emote coloured as a rainbow",
|
||||||
"Unrecognised command:": "Unrecognised command:",
|
"Unrecognised command:": "Unrecognised command:",
|
||||||
"Reason": "Reason",
|
"Reason": "Reason",
|
||||||
"%(targetName)s accepted the invitation for %(displayName)s.": "%(targetName)s accepted the invitation for %(displayName)s.",
|
"%(targetName)s accepted the invitation for %(displayName)s.": "%(targetName)s accepted the invitation for %(displayName)s.",
|
||||||
|
@ -299,7 +302,7 @@
|
||||||
"Show recent room avatars above the room list": "Show recent room avatars above the room list",
|
"Show recent room avatars above the room list": "Show recent room avatars above the room list",
|
||||||
"Group & filter rooms by custom tags (refresh to apply changes)": "Group & filter rooms by custom tags (refresh to apply changes)",
|
"Group & filter rooms by custom tags (refresh to apply changes)": "Group & filter rooms by custom tags (refresh to apply changes)",
|
||||||
"Render simple counters in room header": "Render simple counters in room header",
|
"Render simple counters in room header": "Render simple counters in room header",
|
||||||
"React to messages with emoji": "React to messages with emoji",
|
"React to messages with emoji (refresh to apply changes)": "React to messages with emoji (refresh to apply changes)",
|
||||||
"Enable Emoji suggestions while typing": "Enable Emoji suggestions while typing",
|
"Enable Emoji suggestions while typing": "Enable Emoji suggestions while typing",
|
||||||
"Use compact timeline layout": "Use compact timeline layout",
|
"Use compact timeline layout": "Use compact timeline layout",
|
||||||
"Show a placeholder for removed messages": "Show a placeholder for removed messages",
|
"Show a placeholder for removed messages": "Show a placeholder for removed messages",
|
||||||
|
@ -1135,6 +1138,7 @@
|
||||||
"Filter results": "Filter results",
|
"Filter results": "Filter results",
|
||||||
"Explore Room State": "Explore Room State",
|
"Explore Room State": "Explore Room State",
|
||||||
"Explore Account Data": "Explore Account Data",
|
"Explore Account Data": "Explore Account Data",
|
||||||
|
"View Servers in Room": "View Servers in Room",
|
||||||
"Toolbox": "Toolbox",
|
"Toolbox": "Toolbox",
|
||||||
"Developer Tools": "Developer Tools",
|
"Developer Tools": "Developer Tools",
|
||||||
"An error has occurred.": "An error has occurred.",
|
"An error has occurred.": "An error has occurred.",
|
||||||
|
@ -1330,6 +1334,7 @@
|
||||||
"Enter email address (required on this homeserver)": "Enter email address (required on this homeserver)",
|
"Enter email address (required on this homeserver)": "Enter email address (required on this homeserver)",
|
||||||
"Doesn't look like a valid email address": "Doesn't look like a valid email address",
|
"Doesn't look like a valid email address": "Doesn't look like a valid email address",
|
||||||
"Enter password": "Enter password",
|
"Enter password": "Enter password",
|
||||||
|
"Password is allowed, but unsafe": "Password is allowed, but unsafe",
|
||||||
"Nice, strong password!": "Nice, strong password!",
|
"Nice, strong password!": "Nice, strong password!",
|
||||||
"Keep going...": "Keep going...",
|
"Keep going...": "Keep going...",
|
||||||
"Passwords don't match": "Passwords don't match",
|
"Passwords don't match": "Passwords don't match",
|
||||||
|
|
|
@ -120,7 +120,7 @@ export const SETTINGS = {
|
||||||
},
|
},
|
||||||
"feature_reactions": {
|
"feature_reactions": {
|
||||||
isFeature: true,
|
isFeature: true,
|
||||||
displayName: _td("React to messages with emoji"),
|
displayName: _td("React to messages with emoji (refresh to apply changes)"),
|
||||||
supportedLevels: LEVELS_FEATURE,
|
supportedLevels: LEVELS_FEATURE,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
|
67
src/utils/colour.js
Normal file
67
src/utils/colour.js
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export function hueToRGB(h, s, l) {
|
||||||
|
const c = s * (1 - Math.abs(2 * l - 1));
|
||||||
|
const x = c * (1 - Math.abs((h / 60) % 2 - 1));
|
||||||
|
const m = l - c / 2;
|
||||||
|
|
||||||
|
let r = 0;
|
||||||
|
let g = 0;
|
||||||
|
let b = 0;
|
||||||
|
|
||||||
|
if (0 <= h && h < 60) {
|
||||||
|
r = c;
|
||||||
|
g = x;
|
||||||
|
b = 0;
|
||||||
|
} else if (60 <= h && h < 120) {
|
||||||
|
r = x;
|
||||||
|
g = c;
|
||||||
|
b = 0;
|
||||||
|
} else if (120 <= h && h < 180) {
|
||||||
|
r = 0;
|
||||||
|
g = c;
|
||||||
|
b = x;
|
||||||
|
} else if (180 <= h && h < 240) {
|
||||||
|
r = 0;
|
||||||
|
g = x;
|
||||||
|
b = c;
|
||||||
|
} else if (240 <= h && h < 300) {
|
||||||
|
r = x;
|
||||||
|
g = 0;
|
||||||
|
b = c;
|
||||||
|
} else if (300 <= h && h < 360) {
|
||||||
|
r = c;
|
||||||
|
g = 0;
|
||||||
|
b = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [Math.round((r + m) * 255), Math.round((g + m) * 255), Math.round((b + m) * 255)];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function textToHtmlRainbow(str) {
|
||||||
|
const frequency = 360 / str.length;
|
||||||
|
|
||||||
|
return str.split("").map((c, i) => {
|
||||||
|
const [r, g, b] = hueToRGB(i * frequency, 1.0, 0.5);
|
||||||
|
return '<font color="#' +
|
||||||
|
r.toString(16).padStart(2, "0") +
|
||||||
|
g.toString(16).padStart(2, "0") +
|
||||||
|
b.toString(16).padStart(2, "0") +
|
||||||
|
'">' + c + '</font>';
|
||||||
|
}).join("");
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue