tuqqu / tui-chan

Terminal User Interface for 4chan
MIT License
33 stars 0 forks source link

Unexpected Shutdown When Selecting Board #6

Open Anthhon opened 4 months ago

Anthhon commented 4 months ago

I couldn't determine if this behavior is intended in the application, but when the application is just started and the user presses 'D' to select a Board from the BoardList, the application completely shuts down, similar to pressing 'Q'.

Upon inspecting the main.rs application loop, it appears that this behavior is arising from the following code section:

                 _ if input == keybinds.right => {

                    ...

                    match selected_field {
                        SelectedField::ThreadList => {
                            selected_field = SelectedField::Thread;
                            app.set_shown_thread(true);
                            app.set_shown_board_list(false);

                            let mut thread: Vec<ThreadPost> = vec![];
                            runtime.block_on(async {
                                let result = client
                                    .get_thread(
                                        app.selected_board().board(),
                                        app.selected_thread().posts().first().unwrap().no() as u64,
                                    )
                                    .await;
                                match result {
                                    Ok(data) => thread = data,
                                    Err(err) => eprintln!("{:#?}", err),
                                };

                                app.fill_thread(thread);
                                app.thread.advance_by(1);
                            });
                        }
                        _ => {}
                    };
                }

                ...

                };

At the start of the application, no board is selected. Therefore, when attempting to match the selected_field, the application terminates.

If this behavior is intended, we can consider closing this PR. However, it seems a bit odd to close the app without intending to do so. A potential fix would be to ignore the user input if there is no selected_field set.

tuqqu commented 1 week ago

Hey! I could not replicate the described bug, however, I found a similar issue that occurs when fullscreen is triggered first. Subsequent keystrokes may then crash the app.

the fix is released