mirror of
https://git.quad4.io/RNS-Things/MeshChatX.git
synced 2026-10-23 12:12:52 +00:00
refactor(rns): streamline RNS reload process with loading indicators in UI components
This commit is contained in:
5 files changed
+24
-2
No files matched your search
@@ -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 = (
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -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");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user