Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow diplayed reaction values to contain anything #3186

Merged
merged 2 commits into from
Jul 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion res/css/views/messages/_ReactionsRowButton.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

.mx_ReactionsRowButton {
display: inline-block;
display: inline-flex;
height: 20px;
line-height: 21px;
margin-right: 6px;
Expand All @@ -35,3 +35,11 @@ limitations under the License.
border-color: $reaction-row-button-selected-border-color;
}
}

.mx_ReactionsRowButton_content {
max-width: 100px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
padding-right: 4px;
}
11 changes: 1 addition & 10 deletions src/HtmlUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,10 @@ const VARIATION_SELECTOR = String.fromCharCode(0xFE0F);
* need emojification.
* unicodeToImage uses this function.
*/
export function mightContainEmoji(str) {
function mightContainEmoji(str) {
return SURROGATE_PAIR_PATTERN.test(str) || SYMBOL_PATTERN.test(str);
}

/**
* Returns true if the string definitely contains a single emoji.
* @param {String} str String to test
* @return {Boolean}
*/
export function isSingleEmoji(str) {
return mightContainEmoji(str) && SINGLE_EMOJI_REGEX.test(str);
}

/**
* Returns the shortcode for an emoji character.
*
Expand Down
4 changes: 0 additions & 4 deletions src/components/views/messages/ReactionsRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import PropTypes from 'prop-types';
import sdk from '../../../index';
import { _t } from '../../../languageHandler';
import { isContentActionable } from '../../../utils/EventUtils';
import { isSingleEmoji } from '../../../HtmlUtils';
import MatrixClientPeg from '../../../MatrixClientPeg';

// The maximum number of reactions to initially show on a message.
Expand Down Expand Up @@ -115,9 +114,6 @@ export default class ReactionsRow extends React.PureComponent {

const ReactionsRowButton = sdk.getComponent('messages.ReactionsRowButton');
let items = reactions.getSortedAnnotationsByKey().map(([content, events]) => {
if (!isSingleEmoji(content)) {
return null;
}
const count = events.size;
if (!count) {
return null;
Expand Down
7 changes: 6 additions & 1 deletion src/components/views/messages/ReactionsRowButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ export default class ReactionsRowButton extends React.PureComponent {
onMouseOver={this.onMouseOver}
onMouseOut={this.onMouseOut}
>
{content} {count}
<span className="mx_ReactionsRowButton_content">
{content}
</span>
<span className="mx_ReactionsRowButton_count">
{count}
</span>
{tooltip}
</span>;
}
Expand Down