Closed gustavo434 closed 3 months ago
You can currently do:
return timeline.startSearch(
requestHistoryCount: 1000,
limit: 32,
searchFunc: (Event event) => event.messageType == MessageTypes.Image,
);
Is that sufficient for your usecase? (You obviously can extend that filter to more message types)
Thank you for your response. The approach using timeline.startSearch
with a custom filter is helpful, but it doesn't fully address the core issue I mentioned.
If I understand correctly, this method involves fetching every message in the room and then filtering based on the searchFunc
. This can be quite resource-intensive in rooms with thousands of messages, especially when we only need a specific subset of those messages (attachments). This approach can significantly impact performance, particularly on mobile devices.
Implementing a way to directly retrieve only certain message types would greatly enhance performance. This is why a messageTypesFilter
parameter within the getTimeline
function would be highly beneficial, as it would allow us to pull only the necessary messages from the start.
Thanks for your support!
Hello, I think the Timeline.startSearch method is the only way we can do this in an environment with encrypted messages.
For unencrypted rooms, there is this API endpoint: https://spec.matrix.org/v1.10/client-server-api/#get_matrixclientv3roomsroomidmessages but it looks like the RoomEventFilter
has no way to filter for msgtype
so this is not gonna help. So afaik Matrix just does not offer a better solution yet 😟
Closing this as this is a question and not an issue
(The roomfilter can filter by contains_url
, which often is equivalent in unencrypted rooms)
Preflight Checklist
Describe your problem
I'm currently having a hard time figuring out a good solution to retrieve the attachments of a room without having to pull every single event that's not an attachment in the process.
Describe your ideal solution
It would be ideal if we could get a new function similar to
getTimeline
but for attachments only.Another possible solution would be to let us pass an optional
List<MessageTypes>? messageTypesFilter
as a parameter ongetTimeline
so that we have the option to receive a filtered timeline.In my case I would call:
Version
No response
Security requirements
No response
Additional Context
No response