feat: remove precurrentitemsunload

This commit is contained in:
2025-05-26 09:43:48 +02:00
parent 5cfb556dff
commit c4c901f1d4
2 changed files with 0 additions and 25 deletions

View File

@@ -3,25 +3,13 @@ usage_number: locked(u16) = .{ .data = 0 },
current_items: locked(?[]Arc(*models.Item).Weak) = .{ .data = null },
allocator: std.mem.Allocator,
appState: AppState,
_private: Private,
const Private = struct {
preCurrentItemsUnload: Observer(*Tab),
};
pub fn init(model: *Self, allocator: std.mem.Allocator, appState: AppState) !void {
model.* = Self{
.allocator = allocator,
.appState = appState,
._private = .{
.preCurrentItemsUnload = Observer(*Tab){
.ctx = @ptrCast(@alignCast(model)),
.update = preCurrentItemsUnload,
},
},
};
try model.appState.tabPreCurrentItemsUnload.attach(&model._private.preCurrentItemsUnload);
}
pub fn updateCurrentItems(self: *Self, tab_current_items: *std.ArrayList(Arc(*models.Item))) !void {
@@ -65,14 +53,6 @@ pub fn updateCurrentItems(self: *Self, tab_current_items: *std.ArrayList(Arc(*mo
self.current_items.data = items;
}
pub fn preCurrentItemsUnload(ctx: *anyopaque, tab: *Tab) void {
const self: *Self = @ptrCast(@alignCast(ctx));
if (tab == self.appState.currentTab) {
// @panic("asdasdasd");
self.resetCurrentItems();
}
}
fn resetCurrentItems(self: *@This()) void {
self.current_items.mutex.lock();
defer self.current_items.mutex.unlock();
@@ -89,7 +69,6 @@ fn resetCurrentItems(self: *@This()) void {
}
pub fn deinit(self: *@This()) void {
self.appState.tabPreCurrentItemsUnload.detach(&self._private.preCurrentItemsUnload);
self.appState.deinit();
self.resetCurrentItems();

View File

@@ -4,7 +4,6 @@ pub const Tab = struct {
currentItems: locked(?std.ArrayList(Arc(*Item))),
currentLocationChanged: Observable(?*Container),
currentItemsChanged: bool = false,
preCurrentItemsUnload: Observable(*Tab),
threadPool: *std.Thread.Pool,
rootProvider: *RootProvider,
@@ -21,7 +20,6 @@ pub const Tab = struct {
.currentLocation = null,
.threadPool = threadPool,
.rootProvider = rootProvider,
.preCurrentItemsUnload = Observable(*Tab).init(allocator),
};
}
@@ -60,8 +58,6 @@ pub const Tab = struct {
self.currentItems.mutex.lock();
defer self.currentItems.mutex.unlock();
self.preCurrentItemsUnload.notify(self);
const data = self.currentItems.data;
self.currentItems.data = null;
if (data) |currentItems| {