Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat(courses): refactor to use pluginInvoke for session and course operations

Tonhoaf8e68c9c3b5
diff --git a/src/routes/courses/astronmembers/+page.svelte b/src/routes/courses/astronmembers/+page.svelte
index 1465a3e8..0b3219ae 100644
--- a/src/routes/courses/astronmembers/+page.svelte
+++ b/src/routes/courses/astronmembers/+page.svelte
@@ -1,5 +1,5 @@
<script lang="ts">
- import { invoke } from "@tauri-apps/api/core";
+ import { pluginInvoke } from "$lib/plugin-invoke";
import { open } from "@tauri-apps/plugin-dialog";
import CourseCard from "$components/hotmart/CourseCard.svelte";
import { showToast } from "$lib/stores/toast-store.svelte";
@@ -78,7 +78,7 @@
async function checkSession() {
try {
- const result = await invoke<string>("astronmembers_check_session");
+ const result = await pluginInvoke<string>("courses", "astronmembers_check_session");
sessionEmail = result;
loggedIn = true;
loadCourses();
@@ -93,7 +93,7 @@
error = "";
loading = true;
try {
- const result = await invoke<string>("astronmembers_login", { email, password, siteUrl });
+ const result = await pluginInvoke<string>("courses", "astronmembers_login", { email, password, siteUrl });
sessionEmail = result || email;
loggedIn = true;
loadCourses();
@@ -109,7 +109,7 @@
error = "";
loading = true;
try {
- const result = await invoke<string>("astronmembers_login_token", { token: token.trim(), siteUrl });
+ const result = await pluginInvoke<string>("courses", "astronmembers_login_token", { token: token.trim(), siteUrl });
sessionEmail = result || "Token";
loggedIn = true;
loadCourses();
@@ -122,7 +122,7 @@
async function handleLogout() {
try {
- await invoke("astronmembers_logout");
+ await pluginInvoke("courses", "astronmembers_logout");
} catch {
}
loggedIn = false;
@@ -136,7 +136,7 @@
loadingCourses = true;
coursesError = "";
try {
- courses = await invoke("astronmembers_list_courses");
+ courses = await pluginInvoke("courses", "astronmembers_list_courses");
currentPage = 1;
} catch (e: any) {
coursesError = typeof e === "string" ? e : e.message ?? $t('hotmart.courses_error');
@@ -182,7 +182,7 @@
}
try {
- await invoke("start_astronmembers_download", {
+ await pluginInvoke("courses", "start_astronmembers_download", {
courseJson: JSON.stringify(course),
outputDir,
});
@@ -200,7 +200,7 @@
loadingCourses = true;
coursesError = "";
try {
- courses = await invoke("astronmembers_refresh_courses");
+ courses = await pluginInvoke("courses", "astronmembers_refresh_courses");
currentPage = 1;
} catch (e: any) {
coursesError = typeof e === "string" ? e : e.message ?? $t('hotmart.courses_error');