chore: adapt latest changes from GPUI and nostr-sdk

This commit is contained in:
2025-01-30 08:03:39 +07:00
parent 72a6d79bc5
commit 82f18fc478
19 changed files with 276 additions and 186 deletions

View File

@@ -268,7 +268,7 @@ impl Dock {
) -> impl IntoElement {
let axis = self.placement.axis();
let neg_offset = -HANDLE_PADDING;
let view = cx.model().clone();
let view = cx.entity().clone();
div()
.id("resize-handle")
@@ -336,7 +336,7 @@ impl Dock {
// Get the size of the left dock if it's open and not the current dock
if let Some(left_dock) = &dock_area.left_dock {
if left_dock.entity_id() != cx.model().entity_id() {
if left_dock.entity_id() != cx.entity().entity_id() {
let left_dock_read = left_dock.read(cx);
if left_dock_read.is_open() {
left_dock_size = left_dock_read.size;
@@ -346,7 +346,7 @@ impl Dock {
// Get the size of the right dock if it's open and not the current dock
if let Some(right_dock) = &dock_area.right_dock {
if right_dock.entity_id() != cx.model().entity_id() {
if right_dock.entity_id() != cx.entity().entity_id() {
let right_dock_read = right_dock.read(cx);
if right_dock_read.is_open() {
right_dock_size = right_dock_read.size;
@@ -409,7 +409,7 @@ impl Render for Dock {
})
.child(self.render_resize_handle(window, cx))
.child(DockElement {
view: cx.model().clone(),
view: cx.entity().clone(),
})
}
}

View File

@@ -355,7 +355,7 @@ impl DockArea {
cx: &mut Context<Self>,
) {
self.subscribe_item(&panel, window, cx);
let weak_self = cx.model().downgrade();
let weak_self = cx.entity().downgrade();
self.left_dock = Some(cx.new(|cx| {
let mut dock = Dock::left(weak_self.clone(), window, cx);
if let Some(size) = size {
@@ -377,7 +377,7 @@ impl DockArea {
cx: &mut Context<Self>,
) {
self.subscribe_item(&panel, window, cx);
let weak_self = cx.model().downgrade();
let weak_self = cx.entity().downgrade();
self.bottom_dock = Some(cx.new(|cx| {
let mut dock = Dock::bottom(weak_self.clone(), window, cx);
if let Some(size) = size {
@@ -399,7 +399,7 @@ impl DockArea {
cx: &mut Context<Self>,
) {
self.subscribe_item(&panel, window, cx);
let weak_self = cx.model().downgrade();
let weak_self = cx.entity().downgrade();
self.right_dock = Some(cx.new(|cx| {
let mut dock = Dock::right(weak_self.clone(), window, cx);
if let Some(size) = size {
@@ -534,7 +534,7 @@ impl DockArea {
window: &mut Window,
cx: &mut Context<Self>,
) {
let weak_self = cx.model().downgrade();
let weak_self = cx.entity().downgrade();
match placement {
DockPlacement::Left => {
if let Some(dock) = self.left_dock.as_ref() {
@@ -577,7 +577,7 @@ impl DockArea {
}
DockPlacement::Center => {
self.items
.add_panel(panel, &cx.model().downgrade(), window, cx);
.add_panel(panel, &cx.entity().downgrade(), window, cx);
}
}
}
@@ -717,7 +717,7 @@ impl EventEmitter<DockEvent> for DockArea {}
impl Render for DockArea {
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let view = cx.model().clone();
let view = cx.entity().clone();
div()
.id("dock-area")

View File

@@ -191,7 +191,7 @@ impl StackPanel {
return;
}
let view = cx.model().clone();
let view = cx.entity().clone();
window.defer(cx, {
let panel = panel.clone();
@@ -289,7 +289,7 @@ impl StackPanel {
return;
}
let view = cx.model().clone();
let view = cx.entity().clone();
if let Some(parent) = self.parent.as_ref() {
_ = parent.update(cx, |parent, cx| {
parent.remove_panel(Arc::new(view.clone()), window, cx);

View File

@@ -284,7 +284,7 @@ impl TabPanel {
return;
}
let tab_view = cx.model().clone();
let tab_view = cx.entity().clone();
if let Some(stack_panel) = self.stack_panel.as_ref() {
_ = stack_panel.update(cx, |view, cx| {
@@ -353,7 +353,7 @@ impl TabPanel {
cx: &mut Context<Self>,
) -> impl IntoElement {
let is_zoomed = self.is_zoomed && state.zoomable;
let view = cx.model().clone();
let view = cx.entity().clone();
let build_popup_menu = move |this, cx: &App| view.read(cx).popup_menu(this, cx);
// TODO: Do not show MenuButton if there is no menu items
@@ -413,7 +413,7 @@ impl TabPanel {
return None;
}
let view_entity_id = cx.model().entity_id();
let view_entity_id = cx.entity().entity_id();
let toggle_button_panels = dock_area.toggle_button_panels;
// Check if current TabPanel's entity_id matches the one stored in DockArea for this placement
@@ -486,7 +486,7 @@ impl TabPanel {
window: &mut Window,
cx: &mut Context<Self>,
) -> impl IntoElement {
let view = cx.model().clone();
let view = cx.entity().clone();
let Some(dock_area) = self.dock_area.upgrade() else {
return div().into_any_element();
@@ -800,7 +800,7 @@ impl TabPanel {
cx: &mut Context<Self>,
) {
let panel = drag.panel.clone();
let is_same_tab = drag.tab_panel == cx.model();
let is_same_tab = drag.tab_panel == cx.entity();
// If target is same tab, and it is only one panel, do nothing.
if is_same_tab && ix.is_none() {
@@ -863,7 +863,7 @@ impl TabPanel {
let ix = stack_panel
.read(cx)
.index_of_panel(Arc::new(cx.model().clone()))
.index_of_panel(Arc::new(cx.entity().clone()))
.unwrap_or_default();
if parent_axis.is_vertical() && placement.is_vertical() {
@@ -892,10 +892,10 @@ impl TabPanel {
});
} else {
// 1. Create new StackPanel with new axis
// 2. Move cx.model() from parent StackPanel to the new StackPanel
// 2. Move cx.entity() from parent StackPanel to the new StackPanel
// 3. Add the new TabPanel to the new StackPanel at the correct index
// 4. Add new StackPanel to the parent StackPanel at the correct index
let tab_panel = cx.model().clone();
let tab_panel = cx.entity().clone();
// Try to use the old stack panel, not just create a new one, to avoid too many nested stack panels
let new_stack_panel = if stack_panel.read(cx).panels_len() <= 1 {