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

[OTHER] move the message list to its own component #663

Closed
Dun-sin opened this issue Aug 18, 2024 · 4 comments · Fixed by #721 or #723
Closed

[OTHER] move the message list to its own component #663

Dun-sin opened this issue Aug 18, 2024 · 4 comments · Fixed by #721 or #723
Labels
7 days Not more than 7 days(1week) to raise a PR frontend this issue requires knowlegde of frontend hacktoberfest 🏁 status: ready for dev issue is ready to be worked on up for grabs anyone can ask to work on this

Comments

@Dun-sin
Copy link
Owner

Dun-sin commented Aug 18, 2024

What would you like to share?

<div
key={id}
id={`message-${id}`}
className={`
flex flex-col gap-2 py-2 duration-500 transition-all
${hasActiveReply ? 'bg-[#FF9F1C]/25 border-[#FF9F1C]' : ''},
${hasActiveReply ? (isSender ? 'border-r-[3.5px]' : 'border-l-[3.5px]') : ''}`}
>
{replyTo && (
<div
className={`
max-w-[80%] md:max-w-[50%] min-w-[10px] flex gap-2 items-center
${sender.toString() === senderId.toString() ? 'self-end' : ''}
${repliedMessage ? 'cursor-pointer' : ''}
`}
onClick={() => scrollToMessage(replyTo)}
>
<div className="truncate border-b-4 border-[#FF9F1C] p-1">
{repliedMessage ? (
typeof repliedMessage.message === 'string' ? (
<div
className="message-reply-container flex flex-nowrap items-center gap-2"
dangerouslySetInnerHTML={{
__html: md.render(repliedMessage.message),
}}
/>
) : (
repliedMessage.message
)
) : (
<p className="text-gray-400 uppercase text-sm italic">
Original Message Deleted
</p>
)}
</div>
<div
className={sender.toString() !== senderId.toString() ? 'order-first' : ''}
>
{sender.toString() === senderId.toString() ? (
<BsArrow90DegLeft className="fill-white text-2xl" />
) : (
<BsArrow90DegRight className="fill-white text-2xl" />
)}
</div>
</div>
)}
<div
className={`w-full flex text-white relative mb-2 ${
isSender ? 'justify-end' : 'justify-start'
}`}
>
<div
className={`flex flex-col mb-[2px] min-w-[10px] mdl:max-w-[80%] max-w-[50%] ${
isSender ? 'items-end' : 'items-start'
}`}
>
{containsBadword && !isSender && !badwordChoices[id] ? (
<div className="dark:text-white text-black flex flex-col border-red border w-full rounded-r-md p-3">
<p>Your buddy is trying to send you a bad word</p>
<div className="flex w-full gap-6">
<span
onClick={() => showBadword(id)}
className="text-sm cursor-pointer"
>
See
</span>
<span
onClick={() => hideBadword(id)}
className="text-red text-sm cursor-pointer"
>
Hide
</span>
</div>
</div>
) : (
<>
<div
className={`chat bg-red p-3 break-all will-change-auto flex gap-6 items-center text ${
isSender
? 'justify-between bg-secondary rounded-l-md'
: 'rounded-r-md'
}`}
>
{typeof message === 'string' ? (
<span
dangerouslySetInnerHTML={{
__html: md.render(
badwordChoices[id] === 'hide'
? badwords.filter(message)
: badwordChoices[id] === 'show'
? message
: message
),
}}
/>
) : badwordChoices[id] === 'hide' ? (
badwords.filter(message)
) : badwordChoices[id] === 'show' ? (
message
) : (
message
)}
<DropDownOptions
isSender={isSender && status !== 'pending'}
id={id}
inputRef={inputRef}
cancelEdit={cancelEdit}
setEditing={setEditing}
setReplyId={startReply}
/>
</div>
<div
className={`flex gap-2 items-center ${
isSender ? 'flex-row' : 'flex-row-reverse'
}`}
>
<div
className={`text-[12px] ${
status === 'failed' ? 'text-red-600' : 'text-white'
}`}
>
<MessageStatus
time={getTime(time)}
status={status ?? 'sent'}
iAmTheSender={isSender}
onResend={() => handleResend(id, doSend, state, app)}
/>
</div>
<PreviousMessages
id={id}
isSender={isSender}
isEdited={isEdited}
openPreviousEdit={openPreviousEdit}
openPreviousMessages={openPreviousMessages}
oldMessages={oldMessages}
/>
</div>
<MessageSeen isRead={isRead} isSender={isSender} />
</>
)}
</div>
</div>
</div>

Additional information

Break it down into subcomponents as well:

  • create a component for when we're displaying the bad word warning
    <div className="dark:text-white text-black flex flex-col border-red border w-full rounded-r-md p-3">
    <p>Your buddy is trying to send you a bad word</p>
    <div className="flex w-full gap-6">
    <span
    onClick={() => showBadword(id)}
    className="text-sm cursor-pointer"
    >
    See
    </span>
    <span
    onClick={() => hideBadword(id)}
    className="text-red text-sm cursor-pointer"
    >
    Hide
    </span>
    </div>
    </div>
  • create a component for status
    <div
    className={`flex gap-2 items-center ${
    isSender ? 'flex-row' : 'flex-row-reverse'
    }`}
    >
    <div
    className={`text-[12px] ${
    status === 'failed' ? 'text-red-600' : 'text-white'
    }`}
    >
    <MessageStatus
    time={getTime(time)}
    status={status ?? 'sent'}
    iAmTheSender={isSender}
    onResend={() => handleResend(id, doSend, state, app)}
    />
    </div>
    <PreviousMessages
    id={id}
    isSender={isSender}
    isEdited={isEdited}
    openPreviousEdit={openPreviousEdit}
    openPreviousMessages={openPreviousMessages}
    oldMessages={oldMessages}
    />
    </div>
@Dun-sin Dun-sin added up for grabs anyone can ask to work on this hacktoberfest frontend this issue requires knowlegde of frontend 7 days Not more than 7 days(1week) to raise a PR 🏁 status: ready for dev issue is ready to be worked on labels Aug 18, 2024
Copy link
Contributor

The issue has been unlocked and is now ready for dev. If you would like to work on this issue, you can comment to have it assigned to you.

@zainab-a-ali
Copy link
Contributor

Can I be assigned this issue as well @Dun-sin ?

@wheval
Copy link
Contributor

wheval commented Oct 19, 2024

I want to work on this issue. I can create the component asap. Thanks

@Dun-sin
Copy link
Owner Author

Dun-sin commented Oct 20, 2024

I want to work on this issue. I can create the component asap. Thanks

sure @wheval, thanks for wanting to contribute. Make sure to read the issue description carefully and ask if you have questions on the discord server. Follow the rules here, or your PR won't be accepted and will be closed. Good luck!

@Dun-sin Dun-sin added assigned and removed up for grabs anyone can ask to work on this labels Oct 20, 2024
@Dun-sin Dun-sin added up for grabs anyone can ask to work on this and removed assigned labels Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
7 days Not more than 7 days(1week) to raise a PR frontend this issue requires knowlegde of frontend hacktoberfest 🏁 status: ready for dev issue is ready to be worked on up for grabs anyone can ask to work on this
Projects
None yet
3 participants