diff --git a/apps/app-frontend/src/App.vue b/apps/app-frontend/src/App.vue index d007db6bb..5ba7311c5 100644 --- a/apps/app-frontend/src/App.vue +++ b/apps/app-frontend/src/App.vue @@ -1,5 +1,5 @@ diff --git a/apps/app-frontend/src/components/ui/RunningAppBar.vue b/apps/app-frontend/src/components/ui/RunningAppBar.vue index ef5248373..13c059ab4 100644 --- a/apps/app-frontend/src/components/ui/RunningAppBar.vue +++ b/apps/app-frontend/src/components/ui/RunningAppBar.vue @@ -15,7 +15,7 @@
-
+
Offline
@@ -111,10 +111,9 @@ import { kill_by_uuid as killProfile, get_uuids_by_profile_path as getProfileProcesses, } from '@/helpers/process' -import { loading_listener, process_listener, offline_listener } from '@/helpers/events' +import { loading_listener, process_listener } from '@/helpers/events' import { useRouter } from 'vue-router' import { progress_bars_list } from '@/helpers/state.js' -import { refreshOffline, isOffline } from '@/helpers/utils.js' import ProgressBar from '@/components/ui/ProgressBar.vue' import { handleError } from '@/store/notifications.js' import { mixpanel_track } from '@/helpers/mixpanel' @@ -132,12 +131,12 @@ const showProfiles = ref(false) const currentProcesses = ref(await getRunningProfiles().catch(handleError)) const selectedProfile = ref(currentProcesses.value[0]) -const offline = ref(await isOffline().catch(handleError)) -const refreshInternet = async () => { - offline.value = await refreshOffline().catch(handleError) -} -const unlistenRefresh = await offline_listener(async (b) => { - offline.value = b +const offline = ref(!navigator.onLine) +window.addEventListener('offline', () => { + offline.value = true +}) +window.addEventListener('online', () => { + offline.value = false }) const unlistenProcess = await process_listener(async () => { @@ -265,7 +264,6 @@ onBeforeUnmount(() => { window.removeEventListener('click', handleClickOutsideProfile) unlistenProcess() unlistenLoading() - unlistenRefresh() }) diff --git a/apps/app-frontend/src/helpers/events.js b/apps/app-frontend/src/helpers/events.js index d8899a78d..3bc07bcb9 100644 --- a/apps/app-frontend/src/helpers/events.js +++ b/apps/app-frontend/src/helpers/events.js @@ -17,7 +17,7 @@ // event.payload is the payload object console.log(event) }) - + Putting that in a script will print any emitted signal from rust */ import { listen } from '@tauri-apps/api/event' @@ -93,15 +93,3 @@ export async function command_listener(callback) { export async function warning_listener(callback) { return await listen('warning', (event) => callback(event.payload)) } - -/// Payload for the 'offline' event -/* - OfflinePayload { - offline: bool, true or false - } -*/ -export async function offline_listener(callback) { - return await listen('offline', (event) => { - return callback(event.payload) - }) -} diff --git a/apps/app-frontend/src/helpers/jre.js b/apps/app-frontend/src/helpers/jre.js index 571588443..f490cbf77 100644 --- a/apps/app-frontend/src/helpers/jre.js +++ b/apps/app-frontend/src/helpers/jre.js @@ -14,6 +14,14 @@ JavaVersion { */ +export async function get_java_versions() { + return await invoke('plugin:jre|get_java_versions') +} + +export async function set_java_version(version) { + return await invoke('plugin:jre|set_java_version', { version }) +} + // Finds all the installation of Java 7, if it exists // Returns [JavaVersion] export async function find_filtered_jres(version) { diff --git a/apps/app-frontend/src/helpers/utils.js b/apps/app-frontend/src/helpers/utils.js index 49757ee6e..5432ca710 100644 --- a/apps/app-frontend/src/helpers/utils.js +++ b/apps/app-frontend/src/helpers/utils.js @@ -48,22 +48,3 @@ export const releaseColor = (releaseType) => { return '' } } - -export const openLink = (url) => { - window.__TAURI_INVOKE__('tauri', { - __tauriModule: 'Shell', - message: { - cmd: 'open', - path: url, - }, - }) -} - -export const refreshOffline = async () => { - return await invoke('plugin:utils|refresh_offline', {}) -} - -// returns true/false -export const isOffline = async () => { - return await invoke('plugin:utils|is_offline', {}) -} diff --git a/apps/app-frontend/src/pages/Browse.vue b/apps/app-frontend/src/pages/Browse.vue index 723efbb8a..bd2163052 100644 --- a/apps/app-frontend/src/pages/Browse.vue +++ b/apps/app-frontend/src/pages/Browse.vue @@ -21,22 +21,17 @@ import { useRoute, useRouter } from 'vue-router' import SearchCard from '@/components/ui/SearchCard.vue' import SplashScreen from '@/components/ui/SplashScreen.vue' import { useFetch } from '@/helpers/fetch.js' -import { - check_installed, - get, - get as getInstance, - get_projects as getInstanceProjects, -} from '@/helpers/profile.js' +import { get as getInstance, get_projects as getInstanceProjects } from '@/helpers/profile.js' import { convertFileSrc } from '@tauri-apps/api/tauri' -import { isOffline } from '@/helpers/utils' -import { offline_listener } from '@/helpers/events' - const router = useRouter() const route = useRoute() -const offline = ref(await isOffline()) -const unlistenOffline = await offline_listener((b) => { - offline.value = b +const offline = ref(!navigator.onLine) +window.addEventListener('offline', () => { + offline.value = true +}) +window.addEventListener('online', () => { + offline.value = false }) const breadcrumbs = useBreadcrumbs() @@ -527,8 +522,6 @@ const showLoaders = computed( instanceContext.value === null) || ignoreInstanceLoaders.value, ) - -onUnmounted(() => unlistenOffline())