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 management

Tonho47a24e7507ce
diff --git a/src/routes/courses/afyainternato/+page.svelte b/src/routes/courses/afyainternato/+page.svelte
index 61d83ab7..9d297ff7 100644
--- a/src/routes/courses/afyainternato/+page.svelte
+++ b/src/routes/courses/afyainternato/+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";
@@ -81,7 +81,7 @@
async function checkSession() {
try {
- const result = await invoke<string>("afya_check_session");
+ const result = await pluginInvoke<string>("courses", "afya_check_session");
sessionEmail = result;
loggedIn = true;
loadCourses();
@@ -96,7 +96,7 @@
error = "";
loading = true;
try {
- const result = await invoke<string>("afya_login", { email, password, apiKey });
+ const result = await pluginInvoke<string>("courses", "afya_login", { email, password, apiKey });
sessionEmail = result || email;
loggedIn = true;
loadCourses();
@@ -112,7 +112,7 @@
error = "";
loading = true;
try {
- const result = await invoke<string>("afya_login_token", { token: token.trim(), apiKey: tokenApiKey.trim() });
+ const result = await pluginInvoke<string>("courses", "afya_login_token", { token: token.trim(), apiKey: tokenApiKey.trim() });
sessionEmail = result || "Token";
loggedIn = true;
loadCourses();
@@ -125,7 +125,7 @@
async function handleLogout() {
try {
- await invoke("afya_logout");
+ await pluginInvoke("courses", "afya_logout");
} catch {
}
loggedIn = false;
@@ -139,7 +139,7 @@
loadingCourses = true;
coursesError = "";
try {
- courses = await invoke("afya_list_courses");
+ courses = await pluginInvoke("courses", "afya_list_courses");
currentPage = 1;
} catch (e: any) {
coursesError = typeof e === "string" ? e : e.message ?? $t('hotmart.courses_error');
@@ -183,7 +183,7 @@
}
try {
- await invoke("start_afya_course_download", {
+ await pluginInvoke("courses", "start_afya_course_download", {
courseJson: JSON.stringify(course),
outputDir,
});
@@ -201,7 +201,7 @@
loadingCourses = true;
coursesError = "";
try {
- courses = await invoke("afya_refresh_courses");
+ courses = await pluginInvoke("courses", "afya_refresh_courses");
currentPage = 1;
} catch (e: any) {
coursesError = typeof e === "string" ? e : e.message ?? $t('hotmart.courses_error');