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: Added SystemMessagePinnedMessage contentType #10496

Merged
merged 5 commits into from
May 2, 2023
Merged

Conversation

igor-sirotin
Copy link
Contributor

Fixes #10485

What does the PR do

This PR addresses a change made in status-im/status-go#3414.

I simply added the new ContentType so that it could be correctly processed.
Also, I hided the reply with ContentType=14.

Opened a further request: #10495

Affected areas

Chat

@igor-sirotin igor-sirotin requested review from caybro, jrainville and a team May 1, 2023 16:10
@status-im-auto
Copy link
Member

status-im-auto commented May 1, 2023

Jenkins Builds

Click to see older builds (17)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 02548eb #1 2023-05-01 16:15:29 ~4 min tests/imports 📄log
✔️ 02548eb #1 2023-05-01 16:17:34 ~6 min tests/nim 📄log
✔️ 02548eb #1 2023-05-01 16:19:44 ~8 min macos/aarch64 🍎dmg
✔️ 02548eb #1 2023-05-01 16:22:23 ~11 min macos/x86_64 🍎dmg
✔️ 02548eb #1 2023-05-01 16:24:21 ~13 min linux/x86_64 📦tgz
✔️ 02548eb #1 2023-05-01 16:32:47 ~21 min tests/e2e 📄log
✔️ 02548eb #1 2023-05-01 16:44:01 ~33 min windows/x86_64 💿exe
✔️ 8c0ea64 #2 2023-05-02 10:39:19 ~5 min tests/imports 📄log
✔️ 8c0ea64 #2 2023-05-02 10:40:12 ~6 min tests/nim 📄log
✔️ 8c0ea64 #2 2023-05-02 10:41:08 ~7 min macos/aarch64 🍎dmg
✔️ 8c0ea64 #2 2023-05-02 10:43:04 ~9 min macos/x86_64 🍎dmg
✔️ 8c0ea64 #2 2023-05-02 10:46:08 ~12 min linux/x86_64 📦tgz
✔️ 8c0ea64 #2 2023-05-02 10:52:59 ~18 min tests/e2e 📄log
✔️ 8c0ea64 #2 2023-05-02 11:02:57 ~28 min windows/x86_64 💿exe
✖️ 8aff6bf #3 2023-05-02 14:24:53 ~5 min tests/nim 📄log
✔️ 8aff6bf #3 2023-05-02 14:25:47 ~6 min macos/aarch64 🍎dmg
✔️ 8aff6bf #3 2023-05-02 14:26:00 ~6 min tests/imports 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 29e996c #4 2023-05-02 14:34:15 ~5 min tests/imports 📄log
✖️ 29e996c #4 2023-05-02 14:34:28 ~5 min tests/nim 📄log
✖️ 29e996c #4 2023-05-02 14:35:35 ~7 min tests/e2e 📄log
✔️ 29e996c #4 2023-05-02 14:38:04 ~9 min macos/aarch64 🍎dmg
✔️ 29e996c #4 2023-05-02 14:42:45 ~14 min macos/x86_64 🍎dmg
✔️ 29e996c #4 2023-05-02 14:44:38 ~16 min linux/x86_64 📦tgz
✔️ 2245185 #5 2023-05-02 14:51:58 ~5 min tests/imports 📄log
✔️ 2245185 #5 2023-05-02 14:52:12 ~5 min macos/aarch64 🍎dmg
✔️ 2245185 #5 2023-05-02 14:52:19 ~5 min tests/nim 📄log
✔️ 2245185 #5 2023-05-02 14:56:19 ~9 min macos/x86_64 🍎dmg
✔️ 2245185 #5 2023-05-02 14:58:45 ~12 min linux/x86_64 📦tgz
✔️ 2245185 #5 2023-05-02 15:06:53 ~20 min tests/e2e 📄log
✔️ 2245185 #5 2023-05-02 15:23:55 ~37 min windows/x86_64 💿exe

Copy link
Member

@jrainville jrainville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't part of the ticket, but making it resilient to future crashes would be great

@@ -204,6 +204,8 @@ Loader {
return fetchMoreMessagesButtonComponent
case Constants.messageContentType.systemMessagePrivateGroupType:
return privateGroupHeaderComponent
case Constants.messageContentType.systemMessagePinnedMessage:
return null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it was crashing because we were trying to create a messageCompoennt when it was actually a systemMessagePinnedMessage?

If that's the case, we'll have crashes each time a new MessageType is added.

So we should make the default return null, because then we just show nothing because we didn't implement it yet, and we need to explicitly list the types that should use messageComponent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was crashing on the Nim side in the code like message.contentType.ContentType. I.e. when trying to convert integer to enum. 😐

I agree that it would be great fix that on another level, but thought that it's not easy to implement.
But didn't check that. Let me take a look 🙂

@igor-sirotin
Copy link
Contributor Author

igor-sirotin commented May 2, 2023

Ok, there's another bug coming from this then. @username pinned a message is actually a message in chat. And therefore you might get to this situation, which is definitely strange 🙂

I'll push a fix for this.

image

Copy link
Member

@caybro caybro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modulo what Jo said about the default returning null

@igor-sirotin
Copy link
Contributor Author

About the newMessagesMarker: I implemented a dumb UI for the new contentType.
We definitely want keep this behaviour of the marker to follow Discord UI.

image

Further UI implementation is tracked here: #10495

Copy link
Member

@jrainville jrainville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix on the System message.

Are you planning on returning null like I suggested or do we add another issue?
It should be simple, just default to null and list all the types that use messageComponent?

@igor-sirotin
Copy link
Contributor Author

igor-sirotin commented May 2, 2023

@jrainville
Explicitly listing all types for messageComponent is a good idea, will add that.
But that's not the source of the crash we had, it won't prevent further possible bugs on adding a new ContentType in status-go.

I'm currently adding a robust fix fix for Nim side to check the content type when converting to enum.
Should be fine as part of this PR I think.

@igor-sirotin igor-sirotin requested a review from jrainville May 2, 2023 14:20
@igor-sirotin
Copy link
Contributor Author

Enum fix is pushed. Will quickly implement messageComponent explicit check now.

@igor-sirotin
Copy link
Contributor Author

ok, there we are.
@jrainville check it out please 🙂

Copy link
Member

@caybro caybro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better!

And robust 🤣

Seriously now, much better

@@ -138,7 +139,7 @@ proc toDiscordMessageAuthor*(jsonObj: JsonNode): DiscordMessageAuthor =
discard jsonObj.getProp("localUrl", result.localUrl)


proc toDiscordMessageAttachment*(jsonObj: JsonNOde): DiscordMessageAttachment =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ROFL! What the actual...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When are we getting rid of this NIM nonsense?

Copy link
Member

@jrainville jrainville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go 👏

return messageComponent
case Constants.messageContentType.unknownContentType:
// NOTE: We could display smth like "unknown message type, please upgrade Status to see it".
return null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you remove the return, as it would use the default one instead, but I could be wrong. Anyway, it's not important

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I know, I added it explicitly because with this comment it looked quite strange without a ’return’ 😑

@jrainville jrainville merged commit 2e6ccea into master May 2, 2023
@jrainville jrainville deleted the fix/issue-10485 branch May 2, 2023 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pinning a message makes the app crash when receiving the signal
4 participants