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.

refactor: replace invoke with pluginInvoke for Gumroad API calls

Tonhoc8a25ff1d2b0
diff --git a/src/routes/courses/greatcourses/+page.svelte b/src/routes/courses/greatcourses/+page.svelte
index 4bab09c2..7d9bd0c8 100644
--- a/src/routes/courses/greatcourses/+page.svelte
+++ b/src/routes/courses/greatcourses/+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";
@@ -76,7 +76,7 @@
async function checkSession() {
try {
- const result = await invoke<string>("wondrium_check_session");
+ const result = await pluginInvoke<string>("courses", "wondrium_check_session");
sessionEmail = result;
loggedIn = true;
loadCourses();
@@ -91,7 +91,7 @@
error = "";
loading = true;
try {
- const result = await invoke<string>("wondrium_login", { email, password });
+ const result = await pluginInvoke<string>("courses", "wondrium_login", { email, password });
sessionEmail = result || email;
loggedIn = true;
loadCourses();
@@ -107,7 +107,7 @@
error = "";
loading = true;
try {
- const result = await invoke<string>("wondrium_login_token", { token: token.trim() });
+ const result = await pluginInvoke<string>("courses", "wondrium_login_token", { token: token.trim() });
sessionEmail = result || "Token";
loggedIn = true;
loadCourses();
@@ -120,7 +120,7 @@
async function handleLogout() {
try {
- await invoke("wondrium_logout");
+ await pluginInvoke("courses", "wondrium_logout");
} catch {
}
loggedIn = false;
@@ -134,7 +134,7 @@
loadingCourses = true;
coursesError = "";
try {
- courses = await invoke("wondrium_list_courses");
+ courses = await pluginInvoke("courses", "wondrium_list_courses");
currentPage = 1;
} catch (e: any) {
coursesError = typeof e === "string" ? e : e.message ?? $t('hotmart.courses_error');
@@ -189,7 +189,7 @@
}
try {
- await invoke("start_wondrium_course_download", {
+ await pluginInvoke("courses", "start_wondrium_course_download", {
courseJson: JSON.stringify(course),
outputDir,
});
@@ -207,7 +207,7 @@
loadingCourses = true;
coursesError = "";
try {
- courses = await invoke("wondrium_refresh_courses");
+ courses = await pluginInvoke("courses", "wondrium_refresh_courses");
currentPage = 1;
} catch (e: any) {
coursesError = typeof e === "string" ? e : e.message ?? $t('hotmart.courses_error');
diff --git a/src/routes/courses/gumroad/+page.svelte b/src/routes/courses/gumroad/+page.svelte
index 6193f1e8..9171320a 100644
--- a/src/routes/courses/gumroad/+page.svelte
+++ b/src/routes/courses/gumroad/+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>("gumroad_check_session");
+ const result = await pluginInvoke<string>("courses", "gumroad_check_session");
sessionEmail = result;
loggedIn = true;
loadCourses();
@@ -96,7 +96,7 @@
error = "";
loading = true;
try {
- const result = await invoke<string>("gumroad_login", { email, password });
+ const result = await pluginInvoke<string>("courses", "gumroad_login", { email, password });
sessionEmail = result || email;
loggedIn = true;
loadCourses();
@@ -112,7 +112,7 @@
error = "";
loading = true;
try {
- const result = await invoke<string>("gumroad_login_token", { token: token.trim() });
+ const result = await pluginInvoke<string>("courses", "gumroad_login_token", { token: token.trim() });
sessionEmail = result || "Token";
loggedIn = true;
loadCourses();
@@ -125,7 +125,7 @@
async function handleLogout() {
try {
- await invoke("gumroad_logout");
+ await pluginInvoke("courses", "gumroad_logout");
} catch {
}
loggedIn = false;
@@ -139,7 +139,7 @@
loadingCourses = true;
coursesError = "";
try {
- courses = await invoke("gumroad_list_products");
+ courses = await pluginInvoke("courses", "gumroad_list_products");
currentPage = 1;
} catch (e: any) {
coursesError = typeof e === "string" ? e : e.message ?? $t('hotmart.courses_error');
@@ -183,7 +183,7 @@
}
try {
- await invoke("start_gumroad_download", {
+ await pluginInvoke("courses", "start_gumroad_download", {
productJson: JSON.stringify(product),
outputDir,
});
@@ -201,7 +201,7 @@
loadingCourses = true;
coursesError = "";
try {
- courses = await invoke("gumroad_refresh_products");
+ courses = await pluginInvoke("courses", "gumroad_refresh_products");
currentPage = 1;
} catch (e: any) {
coursesError = typeof e === "string" ? e : e.message ?? $t('hotmart.courses_error');