diff --git a/theseus_gui/src-tauri/src/api/mod.rs b/theseus_gui/src-tauri/src/api/mod.rs index d2a6b0757..9c2f324d0 100644 --- a/theseus_gui/src-tauri/src/api/mod.rs +++ b/theseus_gui/src-tauri/src/api/mod.rs @@ -15,6 +15,7 @@ pub mod profile_create; pub mod settings; pub mod tags; pub mod utils; +pub mod profile_share; pub type Result = std::result::Result; diff --git a/theseus_gui/src-tauri/src/api/profile_share.rs b/theseus_gui/src-tauri/src/api/profile_share.rs new file mode 100644 index 000000000..efa903f69 --- /dev/null +++ b/theseus_gui/src-tauri/src/api/profile_share.rs @@ -0,0 +1,76 @@ +use crate::api::Result; +use theseus::{prelude::*, shared_profile::SharedProfile}; + +pub fn init() -> tauri::plugin::TauriPlugin { + tauri::plugin::Builder::new("profile_share") + .invoke_handler(tauri::generate_handler![ + profile_share_get_all, + profile_share_install, + profile_share_create, + profile_share_inbound_sync, + profile_share_outbound_sync, + profile_share_generate_share_link, + profile_share_accept_share_link + ]) + .build() +} + +// invoke('plugin:profile_share|profile_share_get_all',profile) +#[tauri::command] +pub async fn profile_share_get_all( +) -> Result> { + let res = shared_profile::get_all() + .await?; + Ok(res) +} + +#[tauri::command] +pub async fn profile_share_install( + profile: SharedProfile, +) -> Result { + let res = shared_profile::install(profile) + .await?; + Ok(res) +} + +#[tauri::command] +pub async fn profile_share_create( + path: ProfilePathId +) -> Result<()> { + shared_profile::create(path) + .await?; + Ok(()) +} + +#[tauri::command] +pub async fn profile_share_inbound_sync( + path: ProfilePathId +) -> Result<()> { + shared_profile::inbound_sync(path) + .await?; + Ok(()) +} + +#[tauri::command] +pub async fn profile_share_outbound_sync( + path : ProfilePathId +) -> Result<()> { + shared_profile::outbound_sync(path).await?; + Ok(()) +} + +#[tauri::command] +pub async fn profile_share_generate_share_link( + path : ProfilePathId +) -> Result { + let res = shared_profile::generate_share_link(path).await?; + Ok(res) +} + +#[tauri::command] +pub async fn profile_share_accept_share_link( + link : String +) -> Result<()> { + shared_profile::accept_share_link(link).await?; + Ok(()) +} \ No newline at end of file diff --git a/theseus_gui/src-tauri/src/main.rs b/theseus_gui/src-tauri/src/main.rs index 3a3fa0240..2dd4ae34f 100644 --- a/theseus_gui/src-tauri/src/main.rs +++ b/theseus_gui/src-tauri/src/main.rs @@ -139,6 +139,7 @@ fn main() { .plugin(api::process::init()) .plugin(api::profile::init()) .plugin(api::profile_create::init()) + .plugin(api::profile_share::init()) .plugin(api::settings::init()) .plugin(api::tags::init()) .plugin(api::utils::init()) diff --git a/theseus_gui/src/App.vue b/theseus_gui/src/App.vue index a93e3c66d..1ded159c5 100644 --- a/theseus_gui/src/App.vue +++ b/theseus_gui/src/App.vue @@ -40,12 +40,14 @@ import { TauriEvent } from '@tauri-apps/api/event' import { await_sync, check_safe_loading_bars_complete } from './helpers/state' import { confirm } from '@tauri-apps/api/dialog' import URLConfirmModal from '@/components/ui/URLConfirmModal.vue' +import AcceptSharedProfileModal from '@/components/ui/AcceptSharedProfileModal.vue' import StickyTitleBar from '@/components/ui/tutorial/StickyTitleBar.vue' import OnboardingScreen from '@/components/ui/tutorial/OnboardingScreen.vue' import { install_from_file } from './helpers/pack' const themeStore = useTheming() const urlModal = ref(null) +const sharedProfileConfirmModal = ref(null) const isLoading = ref(true) const videoPlaying = ref(false) @@ -237,6 +239,9 @@ command_listener(async (e) => { source: 'CreationModalFileDrop', }) } + } else if (e.event === 'OpenSharedProfile') { + // Install a shared profile + sharedProfileConfirmModal.value.show(e) } else { // Other commands are URL-based (deep linking) urlModal.value.show(e) @@ -388,6 +393,7 @@ command_listener(async (e) => { + diff --git a/theseus_gui/src/components/GridDisplay.vue b/theseus_gui/src/components/GridDisplay.vue index 615ff5e08..62c854a50 100644 --- a/theseus_gui/src/components/GridDisplay.vue +++ b/theseus_gui/src/components/GridDisplay.vue @@ -169,7 +169,7 @@ const filteredResults = computed(() => { }) } else if (filters.value === 'Downloaded modpacks') { instances = instances.filter((instance) => { - return instance.metadata?.linked_data + return instance.metadata?.linked_data?.modrinth_modpack }) } diff --git a/theseus_gui/src/components/RowDisplay.vue b/theseus_gui/src/components/RowDisplay.vue index 500fa830e..df09a392d 100644 --- a/theseus_gui/src/components/RowDisplay.vue +++ b/theseus_gui/src/components/RowDisplay.vue @@ -170,7 +170,7 @@ const handleOptionsClick = async (args) => { break case 'install': { const versions = await useFetch( - `https://api.modrinth.com/v2/project/${args.item.project_id}/version`, + `https://staging-api.modrinth.com/v2/project/${args.item.project_id}/version`, 'project versions' ) diff --git a/theseus_gui/src/components/ui/AcceptSharedProfileModal.vue b/theseus_gui/src/components/ui/AcceptSharedProfileModal.vue new file mode 100644 index 000000000..3dda939db --- /dev/null +++ b/theseus_gui/src/components/ui/AcceptSharedProfileModal.vue @@ -0,0 +1,89 @@ + + + + + diff --git a/theseus_gui/src/components/ui/Instance.vue b/theseus_gui/src/components/ui/Instance.vue index 2ceadd593..fee2581d5 100644 --- a/theseus_gui/src/components/ui/Instance.vue +++ b/theseus_gui/src/components/ui/Instance.vue @@ -71,7 +71,7 @@ const install = async (e) => { e?.stopPropagation() modLoading.value = true const versions = await useFetch( - `https://api.modrinth.com/v2/project/${props.instance.project_id}/version`, + `https://staging-api.modrinth.com/v2/project/${props.instance.project_id}/version`, 'project versions' ) @@ -82,7 +82,7 @@ const install = async (e) => { packs.length === 0 || !packs .map((value) => value.metadata) - .find((pack) => pack.linked_data?.project_id === props.instance.project_id) + .find((pack) => pack.linked_data?.modrinth_modpack?.project_id === props.instance.project_id) ) { modLoading.value = true await pack_install( diff --git a/theseus_gui/src/components/ui/ModInstallModal.vue b/theseus_gui/src/components/ui/ModInstallModal.vue index a19c53c67..8219a0e38 100644 --- a/theseus_gui/src/components/ui/ModInstallModal.vue +++ b/theseus_gui/src/components/ui/ModInstallModal.vue @@ -247,7 +247,9 @@ const check_valid = computed(() => {
{ ? 'Installing...' : profile.installedMod ? 'Installed' - : profile.metadata.linked_data && profile.metadata.linked_data.locked + : profile.metadata.linked_data?.modrinth_modpack.locked || profile.metadata.linked_data?.shared_profile ? 'Paired' : 'Install' }} diff --git a/theseus_gui/src/components/ui/ModpackVersionModal.vue b/theseus_gui/src/components/ui/ModpackVersionModal.vue index d4e80bf05..0f7797cd6 100644 --- a/theseus_gui/src/components/ui/ModpackVersionModal.vue +++ b/theseus_gui/src/components/ui/ModpackVersionModal.vue @@ -28,7 +28,7 @@ const filteredVersions = computed(() => { }) const modpackVersionModal = ref(null) -const installedVersion = computed(() => props.instance?.metadata?.linked_data?.version_id) +const installedVersion = computed(() => props.instance?.metadata?.linked_data?.modrinth_modpack?.version_id) const installing = computed(() => props.instance.install_stage !== 'installed') const inProgress = ref(false) @@ -49,7 +49,7 @@ const switchVersion = async (versionId) => { :noblur="!themeStore.advancedRendering" >