Browse Source

Add additional logging

master
Kenneth Bruen 8 months ago
parent
commit
8a0aa0b949
Signed by: kbruen
GPG Key ID: C1980A470C3EE5B1
  1. 4
      src/home.zig

4
src/home.zig

@ -57,6 +57,7 @@ fn fetchThread(state: *AppState) !void {
continue; continue;
}; };
defer parsed.deinit(); defer parsed.deinit();
std.debug.print("[home/fetchThread] Parsed data\n", .{});
var results = std.ArrayList(AppState.HSSuggestion).init(allocator); var results = std.ArrayList(AppState.HSSuggestion).init(allocator);
for (parsed.value) |station| { for (parsed.value) |station| {
@ -72,9 +73,11 @@ fn fetchThread(state: *AppState) !void {
} }
} }
} }
std.debug.print("[home/fetchThread] Created results: {} stations\n", .{results.items.len});
state.home_screen_state.mutex.lock(); state.home_screen_state.mutex.lock();
defer state.home_screen_state.mutex.unlock(); defer state.home_screen_state.mutex.unlock();
if (state.home_screen_state.suggestions.len > 0) { if (state.home_screen_state.suggestions.len > 0) {
std.debug.print("[home/fetchThread] Deallocating previous data\n", .{});
for (state.home_screen_state.suggestions) |suggestion| { for (state.home_screen_state.suggestions) |suggestion| {
allocator.free(suggestion.id); allocator.free(suggestion.id);
allocator.free(suggestion.name); allocator.free(suggestion.name);
@ -82,6 +85,7 @@ fn fetchThread(state: *AppState) !void {
allocator.free(state.home_screen_state.suggestions); allocator.free(state.home_screen_state.suggestions);
} }
state.home_screen_state.suggestions = results.toOwnedSlice() catch continue; state.home_screen_state.suggestions = results.toOwnedSlice() catch continue;
std.debug.print("[home/fetchThread] Replaced suggestions\n", .{});
} }
} }

Loading…
Cancel
Save