forked from jitsi/jitsi-meet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(chat/settings) - add ephemeral chat notifications with user sett…
…ings support (jitsi#10617)
- Loading branch information
1 parent
a879606
commit ae95582
Showing
17 changed files
with
332 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// @flow | ||
|
||
import React, { Component } from 'react'; | ||
import { toArray } from 'react-emoji-render'; | ||
|
||
import Linkify from './Linkify'; | ||
|
||
type Props = { | ||
|
||
/** | ||
* The body of the message. | ||
*/ | ||
text: string | ||
}; | ||
|
||
/** | ||
* Renders the content of a chat message. | ||
*/ | ||
class Message extends Component<Props> { | ||
/** | ||
* Initializes a new {@code Message} instance. | ||
* | ||
* @param {Props} props - The props of the component. | ||
* @inheritdoc | ||
*/ | ||
constructor(props: Props) { | ||
super(props); | ||
|
||
// Bind event handlers so they are only bound once for every instance | ||
this._processMessage = this._processMessage.bind(this); | ||
} | ||
|
||
/** | ||
* Parses and builds the message tokens to include emojis and urls. | ||
* | ||
* @returns {Array<string|ReactElement>} | ||
*/ | ||
_processMessage() { | ||
const { text } = this.props; | ||
const message = []; | ||
|
||
// Tokenize the text in order to avoid emoji substitution for URLs | ||
const tokens = text ? text.split(' ') : []; | ||
|
||
const content = []; | ||
|
||
for (const token of tokens) { | ||
if (token.includes('://')) { | ||
|
||
// Bypass the emojification when urls are involved | ||
content.push(token); | ||
} else { | ||
content.push(...toArray(token, { className: 'smiley' })); | ||
} | ||
|
||
content.push(' '); | ||
} | ||
|
||
content.forEach(token => { | ||
if (typeof token === 'string' && token !== ' ') { | ||
message.push(<Linkify key = { token }>{ token }</Linkify>); | ||
} else { | ||
message.push(token); | ||
} | ||
}); | ||
|
||
return message; | ||
} | ||
|
||
_processMessage: () => Array<string | React$Element<*>>; | ||
|
||
/** | ||
* Implements React's {@link Component#render()}. | ||
* | ||
* @returns {ReactElement} | ||
*/ | ||
render() { | ||
return ( | ||
<> | ||
{ this._processMessage() } | ||
</> | ||
); | ||
} | ||
} | ||
|
||
export default Message; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.