WIP: Support for pinned messages #49

Draft
istalri wants to merge 9 commits from istalri/nexus:support_pinned_messages into main
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 - [ ] 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.
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.
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!
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u support_pinned_messages:istalri-support_pinned_messages
git switch istalri-support_pinned_messages

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff istalri-support_pinned_messages
git switch istalri-support_pinned_messages
git rebase main
git switch main
git merge --ff-only istalri-support_pinned_messages
git switch istalri-support_pinned_messages
git rebase main
git switch main
git merge --no-ff istalri-support_pinned_messages
git switch main
git merge --squash istalri-support_pinned_messages
git switch main
git merge --ff-only istalri-support_pinned_messages
git switch main
git merge istalri-support_pinned_messages
git push origin main
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.