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 }, current_items: locked(?[]Arc(*models.Item).Weak) = .{ .data = null },
allocator: std.mem.Allocator, allocator: std.mem.Allocator,
appState: AppState, appState: AppState,
_private: Private,
const Private = struct {
preCurrentItemsUnload: Observer(*Tab),
};
pub fn init(model: *Self, allocator: std.mem.Allocator, appState: AppState) !void { pub fn init(model: *Self, allocator: std.mem.Allocator, appState: AppState) !void {
model.* = Self{ model.* = Self{
.allocator = allocator, .allocator = allocator,
.appState = appState, .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 { 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; 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 { fn resetCurrentItems(self: *@This()) void {
self.current_items.mutex.lock(); self.current_items.mutex.lock();
defer self.current_items.mutex.unlock(); defer self.current_items.mutex.unlock();
@@ -89,7 +69,6 @@ fn resetCurrentItems(self: *@This()) void {
} }
pub fn deinit(self: *@This()) void { pub fn deinit(self: *@This()) void {
self.appState.tabPreCurrentItemsUnload.detach(&self._private.preCurrentItemsUnload);
self.appState.deinit(); self.appState.deinit();
self.resetCurrentItems(); self.resetCurrentItems();

View File

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