Skip to content

Commit 3db8edb

Browse files
committed
remove view_list widget
1 parent 176bcab commit 3db8edb

File tree

3 files changed

+43
-113
lines changed

3 files changed

+43
-113
lines changed

src/home/room_screen.rs

Lines changed: 43 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ live_design! {
8080
use crate::home::event_group::SmallStateGroupHeader;
8181
use crate::rooms_list::*;
8282
use crate::shared::restore_status_view::*;
83-
use crate::shared::view_list::ViewList;
8483
use crate::home::link_preview::LinkPreview;
8584
use link::tsp_link::TspSignIndicator;
8685

@@ -498,16 +497,12 @@ live_design! {
498497
width: Fill,
499498
height: Fit
500499
flow: Down
501-
// As populate_small_state uses PortalList as parameter, create a portal list but do not draw it.
502-
dummy_portal_list = <PortalList> {
503-
height: 0, width: Fill
500+
<PortalList> {
501+
height: Fit, width: Fill
504502
SmallStateEvent = <SmallStateEvent> {}
505503
CondensedMessage = <CondensedMessage> {}
506504
Message = <Message> {}
507505
}
508-
view_list = <ViewList> {
509-
width: Fill
510-
}
511506
}
512507
}
513508
Empty = <Empty> {}
@@ -1039,8 +1034,10 @@ impl Widget for RoomScreen {
10391034
if group_range.start == item_id {
10401035
// This is the first item of a group - render FoldHeader
10411036
if let Some(group) = tl_state.small_state_group_manager.get_group_at_item_id(item_id) {
1042-
let item = populate_small_state_group_header(
1037+
populate_small_state_group_header(
10431038
cx,
1039+
scope,
1040+
walk,
10441041
list,
10451042
item_id,
10461043
room_id,
@@ -1055,7 +1052,6 @@ impl Widget for RoomScreen {
10551052
&self.pinned_events,
10561053
room_screen_widget_uid,
10571054
);
1058-
item.draw_all(cx, scope);
10591055
} else {
10601056
let item = list.item(cx, item_id, id!(Empty));
10611057
item.draw_all(cx, scope);
@@ -4220,6 +4216,8 @@ fn populate_small_state_event(
42204216
/// * `tl_items` - The full list of timeline items
42214217
fn populate_small_state_group_header(
42224218
cx: &mut Cx2d,
4219+
scope: &mut Scope,
4220+
walk: Walk,
42234221
list: &mut PortalList,
42244222
item_id: usize,
42254223
room_id: &OwnedRoomId,
@@ -4233,10 +4231,7 @@ fn populate_small_state_group_header(
42334231
user_power_levels: &UserPowerLevels,
42344232
pinned_events: &[OwnedEventId],
42354233
room_screen_widget_uid: WidgetUid,
4236-
) -> WidgetRef {
4237-
use crate::shared::view_list::ViewListWidgetRefExt;
4238-
4239-
// Get the FoldHeader item from portal list
4234+
) {
42404235
let (fold_item, _existed) = list.item_with_existed(cx, item_id, id!(SmallStateGroupHeader));
42414236
// Set the header summary text
42424237
if let Some(summary) = &group.cached_summary {
@@ -4252,56 +4247,48 @@ fn populate_small_state_group_header(
42524247
user_ids,
42534248
);
42544249
}
4255-
4256-
// Create SmallStateEvent views for each item in the group range (skip first, which is the header)
4257-
let mut widgetref_list = vec![];
4258-
let dummy_portal_list = fold_item.portal_list(ids!(dummy_portal_list));
4259-
if let Some(mut list_ref) = dummy_portal_list.borrow_mut() {
4260-
let list = list_ref.deref_mut();
4261-
for tl_idx in (group_range.start)..group_range.end {
4262-
if let Some(timeline_item) = tl_items.get(tl_idx) {
4263-
let item_drawn_status = ItemDrawnStatus {
4264-
content_drawn: content_drawn_since_last_update.contains(&tl_idx),
4265-
profile_drawn: profile_drawn_since_last_update.contains(&tl_idx),
4266-
};
4267-
if let TimelineItemKind::Event(event_tl_item) = timeline_item.kind() {
4268-
// Create a new SmallStateEvent view from the template
4269-
let (item, item_drawn_status) = match event_tl_item.content() {
4270-
TimelineItemContent::MsgLike(msg_like_content) => match &msg_like_content.kind {
4271-
MsgLikeKind::Redacted => {
4272-
let prev_event = tl_idx.checked_sub(1).and_then(|i| tl_items.get(i));
4273-
populate_message_view(cx, list, tl_idx, room_id, event_tl_item, msg_like_content, prev_event, media_cache, link_preview_cache, user_power_levels, pinned_events, item_drawn_status, room_screen_widget_uid)
4274-
}
4275-
MsgLikeKind::Poll(poll_state) => populate_small_state_event(cx, list, tl_idx, room_id, event_tl_item, poll_state, item_drawn_status),
4276-
MsgLikeKind::UnableToDecrypt(utd) => populate_small_state_event(cx, list, tl_idx, room_id, event_tl_item, utd, item_drawn_status),
4277-
MsgLikeKind::Other(other) => populate_small_state_event(cx, list, tl_idx, room_id, event_tl_item, other, item_drawn_status),
4278-
_ => (list.item_with_existed(cx, tl_idx, id!(Empty)).0, item_drawn_status)
4279-
},
4280-
TimelineItemContent::MembershipChange(membership_change) => populate_small_state_event(cx, list, tl_idx, room_id, event_tl_item, membership_change, item_drawn_status),
4281-
TimelineItemContent::ProfileChange(profile_change) => populate_small_state_event(cx, list, tl_idx, room_id, event_tl_item, profile_change, item_drawn_status),
4282-
TimelineItemContent::OtherState(other_state) => populate_small_state_event(cx, list, tl_idx, room_id, event_tl_item, other_state, item_drawn_status),
4283-
_=> (list.item_with_existed(cx, tl_idx, id!(Empty)).0, item_drawn_status)
4250+
let mut walk = walk;
4251+
walk.height = Size::fit();
4252+
while let Some(item) = fold_item.draw_walk(cx, scope, walk).step() {
4253+
if let Some(mut list_ref) = item.as_portal_list().borrow_mut() {
4254+
let list = list_ref.deref_mut();
4255+
for tl_idx in (group_range.start)..group_range.end {
4256+
if let Some(timeline_item) = tl_items.get(tl_idx) {
4257+
let item_drawn_status = ItemDrawnStatus {
4258+
content_drawn: content_drawn_since_last_update.contains(&tl_idx),
4259+
profile_drawn: profile_drawn_since_last_update.contains(&tl_idx),
42844260
};
4285-
if item_drawn_status.content_drawn {
4286-
content_drawn_since_last_update.insert(tl_idx..tl_idx + 1);
4287-
}
4288-
if item_drawn_status.profile_drawn {
4289-
profile_drawn_since_last_update.insert(tl_idx..tl_idx + 1);
4261+
if let TimelineItemKind::Event(event_tl_item) = timeline_item.kind() {
4262+
// Create a new SmallStateEvent view from the template
4263+
let (item, item_drawn_status) = match event_tl_item.content() {
4264+
TimelineItemContent::MsgLike(msg_like_content) => match &msg_like_content.kind {
4265+
MsgLikeKind::Redacted => {
4266+
let prev_event = tl_idx.checked_sub(1).and_then(|i| tl_items.get(i));
4267+
populate_message_view(cx, list, tl_idx, room_id, event_tl_item, msg_like_content, prev_event, media_cache, link_preview_cache, user_power_levels, pinned_events, item_drawn_status, room_screen_widget_uid)
4268+
}
4269+
MsgLikeKind::Poll(poll_state) => populate_small_state_event(cx, list, tl_idx, room_id, event_tl_item, poll_state, item_drawn_status),
4270+
MsgLikeKind::UnableToDecrypt(utd) => populate_small_state_event(cx, list, tl_idx, room_id, event_tl_item, utd, item_drawn_status),
4271+
MsgLikeKind::Other(other) => populate_small_state_event(cx, list, tl_idx, room_id, event_tl_item, other, item_drawn_status),
4272+
_ => (list.item_with_existed(cx, tl_idx, id!(Empty)).0, item_drawn_status)
4273+
},
4274+
TimelineItemContent::MembershipChange(membership_change) => populate_small_state_event(cx, list, tl_idx, room_id, event_tl_item, membership_change, item_drawn_status),
4275+
TimelineItemContent::ProfileChange(profile_change) => populate_small_state_event(cx, list, tl_idx, room_id, event_tl_item, profile_change, item_drawn_status),
4276+
TimelineItemContent::OtherState(other_state) => populate_small_state_event(cx, list, tl_idx, room_id, event_tl_item, other_state, item_drawn_status),
4277+
_=> (list.item_with_existed(cx, tl_idx, id!(Empty)).0, item_drawn_status)
4278+
};
4279+
if item_drawn_status.content_drawn {
4280+
content_drawn_since_last_update.insert(tl_idx..tl_idx + 1);
4281+
}
4282+
if item_drawn_status.profile_drawn {
4283+
profile_drawn_since_last_update.insert(tl_idx..tl_idx + 1);
4284+
}
4285+
item.draw_all(cx, scope);
42904286
}
4291-
widgetref_list.push(item);
42924287
}
42934288
}
42944289
}
42954290
}
4296-
// Get the ViewList reference from the fold header body
4297-
let mut view_widget = fold_item.view_list(ids!(view_list));
4298-
// Set the views into the ViewList
4299-
view_widget.set_widgetref_list(widgetref_list);
4300-
4301-
fold_item
43024291
}
4303-
4304-
43054292
/// Returns the display name of the sender of the given `event_tl_item`, if available.
43064293
fn get_profile_display_name(event_tl_item: &EventTimelineItem) -> Option<String> {
43074294
if let TimelineDetails::Ready(profile) = event_tl_item.sender_profile() {

src/shared/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ pub mod unread_badge;
1919
pub mod verification_badge;
2020
pub mod restore_status_view;
2121
pub mod image_viewer;
22-
pub mod view_list;
2322
pub mod fold_button_with_text;
2423

2524

@@ -44,6 +43,5 @@ pub fn live_design(cx: &mut Cx) {
4443
restore_status_view::live_design(cx);
4544
confirmation_modal::live_design(cx);
4645
image_viewer::live_design(cx);
47-
view_list::live_design(cx);
4846
fold_button_with_text::live_design(cx);
4947
}

src/shared/view_list.rs

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)