Fix loader handling: only call hide(...) when the loader is shown