diff --git a/meshchatx/meshchat.py b/meshchatx/meshchat.py index 681ecca..862a545 100644 --- a/meshchatx/meshchat.py +++ b/meshchatx/meshchat.py @@ -1263,7 +1263,8 @@ class ReticulumMeshChat: rpc_addrs.append((("127.0.0.1", 37428), "AF_INET")) abstract_unix_addr_in_use_after_wait = False - for i in range(15): + reload_probe_attempts = 3 + for i in range(reload_probe_attempts): all_free = True for addr, family_str in rpc_addrs: try: @@ -1290,7 +1291,7 @@ class ReticulumMeshChat: addr_display = addr[1:] + " (abstract)" print( - f"RPC addr {addr_display} still in use... (attempt {i + 1}/15)", + f"RPC addr {addr_display} still in use... (attempt {i + 1}/{reload_probe_attempts})", ) s.close() is_abstract_unix_addr = ( diff --git a/meshchatx/src/frontend/components/about/AboutPage.vue b/meshchatx/src/frontend/components/about/AboutPage.vue index aaa52cf..b4ee6c7 100644 --- a/meshchatx/src/frontend/components/about/AboutPage.vue +++ b/meshchatx/src/frontend/components/about/AboutPage.vue @@ -1345,12 +1345,14 @@ export default { if (this.reloadingRns) return; try { this.reloadingRns = true; + ToastUtils.loading(this.$t("app.reloading_rns"), 0, "about-rns-reload"); const response = await window.api.post("/api/v1/reticulum/reload"); ToastUtils.success(response?.data?.message || this.$t("app.reloaded_rns")); await this.getAppInfo(); } catch (e) { ToastUtils.error(e.response?.data?.error || this.$t("settings.failed_reload_reticulum")); } finally { + ToastUtils.dismiss("about-rns-reload"); this.reloadingRns = false; } }, diff --git a/meshchatx/src/frontend/components/interfaces/InterfacesPage.vue b/meshchatx/src/frontend/components/interfaces/InterfacesPage.vue index 48a1d6e..d9e6118 100644 --- a/meshchatx/src/frontend/components/interfaces/InterfacesPage.vue +++ b/meshchatx/src/frontend/components/interfaces/InterfacesPage.vue @@ -1277,6 +1277,7 @@ export default { try { this.reloadingRns = true; + ToastUtils.loading(this.$t("app.reloading_rns"), 0, "interfaces-rns-reload"); const response = await window.api.post("/api/v1/reticulum/reload"); ToastUtils.success(response.data.message); GlobalState.hasPendingInterfaceChanges = false; @@ -1286,6 +1287,7 @@ export default { ToastUtils.error(e.response?.data?.error || this.$t("interfaces.failed_reload")); console.error(e); } finally { + ToastUtils.dismiss("interfaces-rns-reload"); this.reloadingRns = false; } }, diff --git a/tests/frontend/AboutPage.test.js b/tests/frontend/AboutPage.test.js index 36240db..d22d931 100644 --- a/tests/frontend/AboutPage.test.js +++ b/tests/frontend/AboutPage.test.js @@ -3,6 +3,16 @@ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest"; import AboutPage from "@/components/about/AboutPage.vue"; import ElectronUtils from "@/js/ElectronUtils"; import DialogUtils from "@/js/DialogUtils"; +import ToastUtils from "@/js/ToastUtils"; + +vi.mock("@/js/ToastUtils", () => ({ + default: { + success: vi.fn(), + error: vi.fn(), + loading: vi.fn(), + dismiss: vi.fn(), + }, +})); describe("AboutPage.vue", () => { let axiosMock; @@ -173,7 +183,9 @@ describe("AboutPage.vue", () => { axiosMock.post.mockResolvedValueOnce({ data: { message: "RNS restarted" } }); await wrapper.vm.restartRns(); + expect(ToastUtils.loading).toHaveBeenCalledWith("app.reloading_rns", 0, "about-rns-reload"); expect(axiosMock.post).toHaveBeenCalledWith("/api/v1/reticulum/reload"); + expect(ToastUtils.dismiss).toHaveBeenCalledWith("about-rns-reload"); }); it("updates app info periodically", async () => { diff --git a/tests/frontend/InterfacesDiscoveryActions.test.js b/tests/frontend/InterfacesDiscoveryActions.test.js index 6147bcc..82d72b0 100644 --- a/tests/frontend/InterfacesDiscoveryActions.test.js +++ b/tests/frontend/InterfacesDiscoveryActions.test.js @@ -1,6 +1,7 @@ import { mount } from "@vue/test-utils"; import { describe, it, expect, vi, beforeEach } from "vitest"; import InterfacesPage from "../../meshchatx/src/frontend/components/interfaces/InterfacesPage.vue"; +import ToastUtils from "../../meshchatx/src/frontend/js/ToastUtils"; vi.mock("../../meshchatx/src/frontend/js/GlobalState", () => ({ default: { @@ -21,6 +22,8 @@ vi.mock("../../meshchatx/src/frontend/js/ToastUtils", () => ({ default: { success: vi.fn(), error: vi.fn(), + loading: vi.fn(), + dismiss: vi.fn(), }, })); @@ -189,6 +192,8 @@ describe("InterfacesPage discovery actions", () => { await wrapper.vm.reloadRns(); + expect(ToastUtils.loading).toHaveBeenCalledWith("app.reloading_rns", 0, "interfaces-rns-reload"); expect(mockAxios.post).toHaveBeenCalledWith("/api/v1/reticulum/reload"); + expect(ToastUtils.dismiss).toHaveBeenCalledWith("interfaces-rns-reload"); }); });