Skip to content

Commit

Permalink
feat(mentions): add mention type
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Stachofsky authored and aimeex3 committed Apr 28, 2020
1 parent 6d75778 commit b276404
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/ComposerQuill/composer.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ class Composer extends React.Component {
object.groupMentions = mentioned.group;
}

object.mentionType = mentioned.mentionType;
// sends the message, if it succeeded then clear the composer
if (send(object)) {
// clear the composer and reset the draft
Expand Down
6 changes: 4 additions & 2 deletions src/components/ComposerQuill/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export function replaceMentions(text, mentions) {
// check if an all mention was inserted to the composer
if (id === 'moderators' || id === 'here') {
mentions.people.forEach((mention, i) => {
sb += `<spark-mention data-object-type='${mention.type}' data-object-id='${mention.id}'>${mention.name}</spark-mention>`;
sb += `<spark-mention data-object-type='${mention.objectType}' data-object-id='${mention.id}'>${mention.name}</spark-mention>`;
if (i < mentions.people.length - 1) {
sb += ', ';
}
Expand Down Expand Up @@ -147,23 +147,25 @@ export function getMentions(quill) {
id: mention.id,
objectType: mention.objectType,
});
mentions.mentionType = 'person';
} else if (mention.objectType === 'groupMention' && mention.id === 'all') {
mentions.group.push({
groupType: mention.id,
objectType: mention.objectType,
});
mentions.mentionType = mention.id;
} else if (
mention.objectType === 'groupMention' &&
mention.items &&
(mention.id === 'moderators' || mention.id === 'here')
) {
mentions.mentionType = mention.id;
const list = JSON.parse(mention.items);

list.forEach((person) => {
mentions.people.push({
id: person.id,
objectType: person.objectType,
type: person.objectType,
name: person.value,
});
});
Expand Down

0 comments on commit b276404

Please sign in to comment.