Fix back navigation after modal fullscreen, fix SQL operator precedence

Navigation:
- Stale {modal:true}/{chartFull:true} history entries after app restart
  caused back gesture to do nothing (no screen to render, no modal open).
  Now global popstate handler skips these stale entries with history.back().

Rust seed import:
- Fixed SQL operator precedence in nutrients_guessed UPDATE:
  WHERE (guessed IS NULL OR guessed = 0) AND name_lower IN (...)
  was previously parsed as: guessed IS NULL OR (guessed = 0 AND ...)
  which matched ALL products with NULL guessed regardless of name.
This commit is contained in:
4aiman 2026-05-23 18:39:28 +03:00
commit 62cdd7740f
2 changed files with 7 additions and 2 deletions

View file

@ -3008,9 +3008,14 @@ function esc(str) {
window.addEventListener("popstate", (e) => {
// If a modal is open, don't handle here (modal has its own handler)
if (document.querySelector(".modal-overlay")) return;
// Stale modal/chart entries left after app restart — skip them
if (e.state && (e.state.modal || e.state.chartFull)) {
history.back();
return;
}
// Pop our nav stack and navigate to previous screen
if (navStack.length > 1) {
navStack.pop(); // remove current
navStack.pop();
const prev = navStack[navStack.length - 1];
renderScreen(prev, true);
} else if (e.state && e.state.screen) {

View file

@ -242,7 +242,7 @@ fn import_seed_products(app: tauri::AppHandle) -> Result<String, String> {
// Sync nutrients_guessed flag
let _ = main_db.execute_batch(
"UPDATE main.products SET nutrients_guessed = 1
WHERE nutrients_guessed IS NULL OR nutrients_guessed = 0
WHERE (nutrients_guessed IS NULL OR nutrients_guessed = 0)
AND name_lower IN (SELECT s.name_lower FROM seed.products s WHERE s.nutrients_guessed = 1)"
);
// Sync micronutrients for products that have them in seed but not in main