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

Fix/ Update Tag class #2200

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
8 changes: 4 additions & 4 deletions components/forum/ChatReply.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ const ChatReply = ({
existingTagId = existingTags.find((t) => t.signature === signature)?.id
}
const tagData = {
tag: tagValue,
label: tagValue,
invitation: reactionInvitation.id,
replyto: note.id,
note: note.id,
forum: note.forum,
signatures: [signature],
signature,
...(existingTagId && { id: existingTagId, ddate: Date.now() }),
}
api
Expand Down Expand Up @@ -326,7 +326,7 @@ const ChatReply = ({

{showReactionPicker && (
<ReactionPicker
options={reactionInvitation.tag.tag.param.enum}
options={reactionInvitation.tag.label.param.enum}
noteReactions={note.reactions}
addOrRemoveTag={addOrRemoveTag}
toggleReactionPicker={toggleReactionPicker}
Expand Down
2 changes: 1 addition & 1 deletion components/forum/Forum.js
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ export default function Forum({
})
})
.then(([newReplies, newTags]) => {
const groupedTags = groupBy(newTags, 'replyto')
const groupedTags = groupBy(newTags, 'note')

let newMessageAuthor = ''
let newMessage = ''
Expand Down
18 changes: 8 additions & 10 deletions lib/forum-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ export function groupTagsByValue(tags) {
for (let i = 0; i < sortedTags.length; i += 1) {
const tag = sortedTags[i]

if (tag.tag && !tag.ddate) {
const existingIndex = groupedTags.findIndex((t) => t[0] === tag.tag)
if (tag.label && !tag.ddate) {
const existingIndex = groupedTags.findIndex((t) => t[0] === tag.label)
const tagInfo = {
id: tag.id,
signature: tag.signatures[0],
signature: tag.signature,
cdate: tag.cdate,
}
if (existingIndex > -1) {
groupedTags[existingIndex][1].push(tagInfo)
} else {
groupedTags.push([tag.tag, [tagInfo]])
groupedTags.push([tag.label, [tagInfo]])
}
}
}
Expand All @@ -50,11 +50,11 @@ export function addTagToReactionsList(reactions, tag) {
const newReactions = []
const newTagInfo = tag.ddate
? null
: { id: tag.id, signature: tag.signatures[0], cdate: tag.cdate }
: { id: tag.id, signature: tag.signature, cdate: tag.cdate }
let reactionExists = false

reactions.forEach((tuple) => {
if (tuple[0] !== tag.tag) {
if (tuple[0] !== tag.label) {
newReactions.push(tuple)
} else {
if (tag.ddate) {
Expand All @@ -71,7 +71,7 @@ export function addTagToReactionsList(reactions, tag) {
}
})
if (!reactionExists && !tag.ddate) {
newReactions.push([tag.tag, [newTagInfo]])
newReactions.push([tag.label, [newTagInfo]])
}
return newReactions
}
Expand Down Expand Up @@ -121,12 +121,10 @@ export function getNoteInvitations(invitations, note) {
})

const tagInvitations = invitations.filter((p) => {
const replyTo = p.tag?.replyto
const invitationExpired = p.expdate && p.expdate < Date.now()
return (
!invitationExpired &&
replyTo &&
(replyTo === note.id || replyTo.param?.withForum === note.forum)
(p.tag?.note?.id === note.id || p.tag?.note?.param?.withForum === note.forum)
)
})

Expand Down
Loading