fix @room
pill href=undefined and @room parsing breaking subsequent pills
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
b8ca65627b
commit
7c3873b449
2 changed files with 14 additions and 10 deletions
|
@ -64,13 +64,17 @@ class PlainWithPillsSerializer {
|
||||||
} else if (node.type == 'emoji') {
|
} else if (node.type == 'emoji') {
|
||||||
return node.data.get('emojiUnicode');
|
return node.data.get('emojiUnicode');
|
||||||
} else if (node.type == 'pill') {
|
} else if (node.type == 'pill') {
|
||||||
|
const completion = node.data.get('completion');
|
||||||
|
// over the wire the @room pill is just plaintext
|
||||||
|
if (completion === '@room') return completion;
|
||||||
|
|
||||||
switch (this.pillFormat) {
|
switch (this.pillFormat) {
|
||||||
case 'plain':
|
case 'plain':
|
||||||
return node.data.get('completion');
|
return completion;
|
||||||
case 'md':
|
case 'md':
|
||||||
return `[${ node.data.get('completion') }](${ node.data.get('href') })`;
|
return `[${ completion }](${ node.data.get('href') })`;
|
||||||
case 'id':
|
case 'id':
|
||||||
return node.data.get('completionId') || node.data.get('completion');
|
return node.data.get('completionId') || completion;
|
||||||
}
|
}
|
||||||
} else if (node.nodes) {
|
} else if (node.nodes) {
|
||||||
return node.nodes.map(this._serializeNode).join('');
|
return node.nodes.map(this._serializeNode).join('');
|
||||||
|
|
|
@ -203,7 +203,7 @@ module.exports = React.createClass({
|
||||||
// update the current node with one that's now taken its place
|
// update the current node with one that's now taken its place
|
||||||
node = pillContainer;
|
node = pillContainer;
|
||||||
}
|
}
|
||||||
} else if (node.nodeType == Node.TEXT_NODE) {
|
} else if (node.nodeType === Node.TEXT_NODE) {
|
||||||
const Pill = sdk.getComponent('elements.Pill');
|
const Pill = sdk.getComponent('elements.Pill');
|
||||||
|
|
||||||
let currentTextNode = node;
|
let currentTextNode = node;
|
||||||
|
@ -232,6 +232,12 @@ module.exports = React.createClass({
|
||||||
if (atRoomRule && pushProcessor.ruleMatchesEvent(atRoomRule, this.props.mxEvent)) {
|
if (atRoomRule && pushProcessor.ruleMatchesEvent(atRoomRule, this.props.mxEvent)) {
|
||||||
// Now replace all those nodes with Pills
|
// Now replace all those nodes with Pills
|
||||||
for (const roomNotifTextNode of roomNotifTextNodes) {
|
for (const roomNotifTextNode of roomNotifTextNodes) {
|
||||||
|
// Set the next node to be processed to the one after the node
|
||||||
|
// we're adding now, since we've just inserted nodes into the structure
|
||||||
|
// we're iterating over.
|
||||||
|
// Note we've checked roomNotifTextNodes.length > 0 so we'll do this at least once
|
||||||
|
node = roomNotifTextNode.nextSibling;
|
||||||
|
|
||||||
const pillContainer = document.createElement('span');
|
const pillContainer = document.createElement('span');
|
||||||
const room = MatrixClientPeg.get().getRoom(this.props.mxEvent.getRoomId());
|
const room = MatrixClientPeg.get().getRoom(this.props.mxEvent.getRoomId());
|
||||||
const pill = <Pill
|
const pill = <Pill
|
||||||
|
@ -243,12 +249,6 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
ReactDOM.render(pill, pillContainer);
|
ReactDOM.render(pill, pillContainer);
|
||||||
roomNotifTextNode.parentNode.replaceChild(pillContainer, roomNotifTextNode);
|
roomNotifTextNode.parentNode.replaceChild(pillContainer, roomNotifTextNode);
|
||||||
|
|
||||||
// Set the next node to be processed to the one after the node
|
|
||||||
// we're adding now, since we've just inserted nodes into the structure
|
|
||||||
// we're iterating over.
|
|
||||||
// Note we've checked roomNotifTextNodes.length > 0 so we'll do this at least once
|
|
||||||
node = roomNotifTextNode.nextSibling;
|
|
||||||
}
|
}
|
||||||
// Nothing else to do for a text node (and we don't need to advance
|
// Nothing else to do for a text node (and we don't need to advance
|
||||||
// the loop pointer because we did it above)
|
// the loop pointer because we did it above)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue