File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed
crates/matrix-sdk-ui/src/spaces Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change 14
14
15
15
use std:: collections:: { BTreeMap , BTreeSet } ;
16
16
17
- use ruma:: OwnedRoomId ;
17
+ use ruma:: { OwnedRoomId , RoomId } ;
18
18
19
19
#[ derive( Debug ) ]
20
20
struct SpaceGraphNode {
@@ -51,14 +51,20 @@ impl SpaceGraph {
51
51
52
52
/// Returns the root nodes of the graph, which are nodes without any
53
53
/// parents.
54
- pub ( super ) fn root_nodes ( & self ) -> Vec < & OwnedRoomId > {
55
- self . nodes . values ( ) . filter ( |node| node. parents . is_empty ( ) ) . map ( |node| & node. id ) . collect ( )
54
+ pub ( super ) fn root_nodes ( & self ) -> Vec < & RoomId > {
55
+ self . nodes
56
+ . values ( )
57
+ . filter ( |node| node. parents . is_empty ( ) )
58
+ . map ( |node| node. id . as_ref ( ) )
59
+ . collect ( )
56
60
}
57
61
58
62
/// Returns the children of a given node. If the node does not exist, it
59
63
/// returns an empty vector.
60
- pub ( super ) fn children_of ( & self , node_id : & OwnedRoomId ) -> Vec < & OwnedRoomId > {
61
- self . nodes . get ( node_id) . map_or ( vec ! [ ] , |node| node. children . iter ( ) . collect ( ) )
64
+ pub ( super ) fn children_of ( & self , node_id : & RoomId ) -> Vec < & RoomId > {
65
+ self . nodes
66
+ . get ( node_id)
67
+ . map_or ( vec ! [ ] , |node| node. children . iter ( ) . map ( |id| id. as_ref ( ) ) . collect ( ) )
62
68
}
63
69
64
70
/// Adds a node to the graph. If the node already exists, it does nothing.
Original file line number Diff line number Diff line change @@ -229,12 +229,12 @@ impl SpaceService {
229
229
joined_spaces
230
230
. iter ( )
231
231
. filter_map ( |room| {
232
- let room_id = room. room_id ( ) . to_owned ( ) ;
232
+ let room_id = room. room_id ( ) ;
233
233
234
- if root_nodes. contains ( & & room_id) {
234
+ if root_nodes. contains ( & room_id) {
235
235
Some ( SpaceRoom :: new_from_known (
236
236
room. clone ( ) ,
237
- graph. children_of ( & room_id) . len ( ) as u64 ,
237
+ graph. children_of ( room_id) . len ( ) as u64 ,
238
238
) )
239
239
} else {
240
240
None
You can’t perform that action at this time.
0 commit comments