Support for pinned messages #49

Merged
Henry-Hiles merged 24 commits from istalri/nexus:support_pinned_messages into main 2026-07-14 19:29:47 -04:00
Member

The first draft to support pinned messages. Fixes #39.

TODO:

  • Check if filtering is necessary for visibility rules and implement it
  • Add pin/unpin to context menu
The first draft to support pinned messages. Fixes #39. TODO: - [ ] Check if filtering is necessary for visibility rules and implement it - [x] Add pin/unpin to context menu
Owner

Hope you don't mind me pushing some small cleanups to your branch ^

Hope you don't mind me pushing some small cleanups to your branch ^
@ -8,6 +8,7 @@ abstract class SendEventRequest with _$SendEventRequest {
required String roomId,
required String type,
required Map<String, dynamic> content,
@Default(null) String? stateKey,
Owner

Not certain where you got this from... It's not valid: https://spec.mau.fi/gomuks/rpc.html#cmd-send-event

Instead, set_state must be used. This will need its own function in ClientController.

Not certain where you got this from... It's not valid: https://spec.mau.fi/gomuks/rpc.html#cmd-send-event Instead, [`set_state`](https://spec.mau.fi/gomuks/rpc.html#cmd-set-state) must be used. This will need its own function in `ClientController`.
Author
Member

Oh then I understood something wrong. I though it was needed for this:

Matrix Spec:

{
"content": {
"pinned": [
"$someevent:example.org"
]
},
"event_id": "$143273582443PhrSn:example.org",
"origin_server_ts": 1432735824653,
"room_id": "!jEsUZKDJdhlrceRyVU:example.org",
"sender": "@example:example.org",
"state_key": "",
"type": "m.room.pinned_events",
"unsigned": {
"age": 1234,
"membership": "join"
}
}

Oh then I understood something wrong. I though it was needed for this: Matrix Spec: > { > "content": { > "pinned": [ > "$someevent:example.org" > ] > }, > "event_id": "$143273582443PhrSn:example.org", > "origin_server_ts": 1432735824653, > "room_id": "!jEsUZKDJdhlrceRyVU:example.org", > "sender": "@example:example.org", > "state_key": "", > "type": "m.room.pinned_events", > "unsigned": { > "age": 1234, > "membership": "join" > } > }
Owner

Ah, well eventually it gets to Matrix, but we actually use gomuks as an SDK essentially, so we use that to e.g. send events. You can reference their docs for a schema of all commands: https://spec.mau.fi/gomuks/rpc.html

Ah, well eventually it gets to Matrix, but we actually use gomuks as an SDK essentially, so we use that to e.g. send events. You can reference their docs for a schema of all commands: https://spec.mau.fi/gomuks/rpc.html
Author
Member

Okay, I see. I will look into it.

Edit: Just read the gomuks spec, seems the set_state is straight forward. At first I was not sure why there needs to be multiple endpoints for events but I then it clicked and yeah it makes sense to separate state events from other events. Although I think it's slightly misleading to have send_event and set_state and not send_state_event or the other way around have also set_reaction etc but maybe that's just me.

Okay, I see. I will look into it. Edit: Just read the gomuks spec, seems the `set_state` is straight forward. At first I was not sure why there needs to be multiple endpoints for events but I then it clicked and yeah it makes sense to separate state events from other events. Although I think it's slightly misleading to have `send_event` and `set_state` and not `send_state_event` or the other way around have also `set_reaction` etc but maybe that's just me.
istalri marked this conversation as resolved
Henry-Hiles changed title from WIP: Support for pinned messages. to WIP: Support for pinned messages 2026-07-06 20:15:18 -04:00
@ -0,0 +50,4 @@
],
),
),
AsyncData(:final value) => ListView.builder(
Owner

I would say instead of this, a SuperSliverView should be used, like we do in the main chat view, and instead of an extra card, just wrap EventRenderer with an InkWell or something. And then, you don't need to set textOnly on EventRenderer.

I would say instead of this, a `SuperSliverView` should be used, like we do in the main chat view, and instead of an extra card, just wrap `EventRenderer` with an `InkWell` or something. And then, you don't need to set `textOnly` on `EventRenderer`.
Owner

Okay, I take it back about SuperSliverView, the performance of ListView seems acceptable here.

Okay, I take it back about `SuperSliverView`, the performance of `ListView` seems acceptable here.
Owner

I've done my other suggestion with not using textOnly.

I've done my other suggestion with not using `textOnly`.
Henry-Hiles marked this conversation as resolved
@ -511,1 +521,3 @@
endDrawer: showMembersByDefault ? null : MemberList(roomId),
endDrawer: showMembersByDefault && memberListOpened.value
? null
: Drawer(
Owner

This isn't a good way to do this, the double scaffold is better. I will push a fix.

This isn't a good way to do this, the double scaffold is better. I will push a fix.
Owner

Done.

Done.
Henry-Hiles marked this conversation as resolved
@ -0,0 +41,4 @@
return .new();
}
Future<void> togglePin(Event event) async {
Owner

I think I'd prefer a removePin and addPin, separate methods. And of course this needs to be called from the context menu. The context menu should have an option of "Pin" if the event is not pinned (not present in pinned events controller), and you have permission to pin, or "Unpin" if the event IS pinned, and you have permission to pin.

I think I'd prefer a `removePin` and `addPin`, separate methods. And of course this needs to be called from the context menu. The context menu should have an option of "Pin" if the event is not pinned (not present in pinned events controller), and you have permission to pin, or "Unpin" if the event IS pinned, and you have permission to pin.
Author
Member

Yeah, makes sense, seperation of concern is a useful standard. This would make it cleaner.

Yeah, makes sense, seperation of concern is a useful standard. This would make it cleaner.
istalri marked this conversation as resolved
Author
Member

@Henry-Hiles wrote in #49 (comment):

Hope you don't mind me pushing some small cleanups to your branch ^

I like the changes, seeing it with rested eyes, I can say I left quite the mess. I will look at it in more detail this evening/night but it looks nice on first glance. THe double Scaffold is required for having the pin drawer above the member list on pc, not sure how this will work exactly on mobile, can I open both simultaneously?

@Henry-Hiles wrote in https://git.federated.nexus/Nexus/nexus/pulls/49#issuecomment-404: > Hope you don't mind me pushing some small cleanups to your branch ^ I like the changes, seeing it with rested eyes, I can say I left quite the mess. I will look at it in more detail this evening/night but it looks nice on first glance. THe double Scaffold is required for having the pin drawer above the member list on pc, not sure how this will work exactly on mobile, can I open both simultaneously?
Owner

not sure how this will work exactly on mobile, can I open both simultaneously?

No, because both are drawers on mobile. So, one being open hides the button to open the other.

> not sure how this will work exactly on mobile, can I open both simultaneously? No, because both are drawers on mobile. So, one being open hides the button to open the other.
Henry-Hiles force-pushed support_pinned_messages from a241530f34 to 81bf1a8302 2026-07-07 15:49:49 -04:00 Compare
Owner

Note: I didn't mean to push that commit "add macos folder" to this branch, I have force pushed to remove it :)

My fault!

Note: I didn't mean to push that commit "add macos folder" to this branch, I have force pushed to remove it :) My fault!
istalri force-pushed support_pinned_messages from 81bf1a8302 to 5fef08b88e 2026-07-11 18:14:06 -04:00 Compare
; We can now also send the state event via the setState call.
`SetStateEvent.content` a `Content`
Henry-Hiles force-pushed support_pinned_messages from 897995667e to 19c9479539 2026-07-14 16:20:41 -04:00 Compare
Pins are state events, thus a .state check
Henry-Hiles changed title from WIP: Support for pinned messages to Support for pinned messages 2026-07-14 19:01:30 -04:00
Henry-Hiles referenced this pull request from a commit 2026-07-14 19:29:49 -04:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Nexus/nexus!49
No description provided.