2023-04-16 10:12:37 -07:00
|
|
|
/*
|
|
|
|
|
Event listeners for interacting with the Rust api
|
|
|
|
|
These are all async functions that return a promise that resolves to the payload object (whatever Rust is trying to deliver)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
callback is a function that takes a single argument, which is the payload object (whatever Rust is trying to deliver)
|
|
|
|
|
|
|
|
|
|
You can call these to await any kind of emitted signal from Rust, and then do something with the payload object
|
|
|
|
|
An example place to put this is at the start of main.js before the state is initialized- that way
|
|
|
|
|
you can listen for any emitted signal from Rust and do something with it as the state is being initialized
|
|
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
import { loading_listener } from '@/helpers/events'
|
|
|
|
|
await loading_listener((event) => {
|
|
|
|
|
// event.event is the event name (useful if you want to use a single callback fn for multiple event types)
|
|
|
|
|
// event.payload is the payload object
|
|
|
|
|
console.log(event)
|
|
|
|
|
})
|
2024-07-24 11:03:19 -07:00
|
|
|
|
2023-04-16 10:12:37 -07:00
|
|
|
Putting that in a script will print any emitted signal from rust
|
|
|
|
|
*/
|
|
|
|
|
import { listen } from '@tauri-apps/api/event'
|
|
|
|
|
|
|
|
|
|
/// Payload for the 'loading' event
|
|
|
|
|
/*
|
|
|
|
|
LoadingPayload {
|
2023-05-08 12:14:08 -07:00
|
|
|
event: {
|
|
|
|
|
type: string, one of "StateInit", "PackDownload", etc
|
|
|
|
|
(Optional fields depending on event type)
|
|
|
|
|
pack_name: name of the pack
|
|
|
|
|
pack_id, optional, the id of the modpack
|
|
|
|
|
pack_version, optional, the version of the modpack
|
|
|
|
|
profile_name: name of the profile
|
|
|
|
|
profile_uuid: unique identification of the profile
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-16 10:12:37 -07:00
|
|
|
loader_uuid: unique identification of the loading bar
|
2023-05-09 19:48:47 -04:00
|
|
|
fraction: number, (as a fraction of 1, how much we've loaded so far). If null, by convention, loading is finished
|
2023-04-16 10:12:37 -07:00
|
|
|
message: message to display to the user
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
export async function loading_listener(callback) {
|
|
|
|
|
return await listen('loading', (event) => callback(event.payload))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Payload for the 'process' event
|
|
|
|
|
/*
|
|
|
|
|
ProcessPayload {
|
|
|
|
|
uuid: unique identification of the process in the state (currently identified by PID, but that will change)
|
|
|
|
|
pid: process ID
|
|
|
|
|
event: event type ("Launched", "Finished")
|
|
|
|
|
message: message to display to the user
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
export async function process_listener(callback) {
|
|
|
|
|
return await listen('process', (event) => callback(event.payload))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Payload for the 'profile' event
|
|
|
|
|
/*
|
|
|
|
|
ProfilePayload {
|
|
|
|
|
uuid: unique identification of the process in the state (currently identified by path, but that will change)
|
|
|
|
|
name: name of the profile
|
2023-08-04 20:33:50 -07:00
|
|
|
profile_path: relative path to profile (used for path identification)
|
|
|
|
|
path: path to profile (used for opening the profile in the OS file explorer)
|
2023-04-16 10:12:37 -07:00
|
|
|
event: event type ("Created", "Added", "Edited", "Removed")
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
export async function profile_listener(callback) {
|
|
|
|
|
return await listen('profile', (event) => callback(event.payload))
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-30 08:11:32 -07:00
|
|
|
/// Payload for the 'command' event
|
|
|
|
|
/*
|
|
|
|
|
CommandPayload {
|
|
|
|
|
event: event type ("InstallMod", "InstallModpack", "InstallVersion"),
|
|
|
|
|
id: string id of the mod/modpack/version to install
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
export async function command_listener(callback) {
|
|
|
|
|
return await listen('command', (event) => {
|
|
|
|
|
callback(event.payload)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-16 10:12:37 -07:00
|
|
|
/// Payload for the 'warning' event
|
|
|
|
|
/*
|
|
|
|
|
WarningPayload {
|
|
|
|
|
message: message to display to the user
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
export async function warning_listener(callback) {
|
|
|
|
|
return await listen('warning', (event) => callback(event.payload))
|
|
|
|
|
}
|
App redesign (#2946)
* Start of app redesign
* format
* continue progress
* Content page nearly done
* Fix recursion issues with content page
* Fix update all alignment
* Discover page progress
* Settings progress
* Removed unlocked-size hack that breaks web
* Revamp project page, refactor web project page to share code with app, fixed loading bar, misc UI/UX enhancements, update ko-fi logo, update arrow icons, fix web issues caused by floating-vue migration, fix tooltip issues, update web tooltips, clean up web hydration issues
* Ads + run prettier
* Begin auth refactor, move common messages to ui lib, add i18n extraction to all apps, begin Library refactor
* fix ads not hiding when plus log in
* rev lockfile changes/conflicts
* Fix sign in page
* Add generated
* (mostly) Data driven search
* Fix search mobile issue
* profile fixes
* Project versions page, fix typescript on UI lib and misc fixes
* Remove unused gallery component
* Fix linkfunction err
* Search filter controls at top, localization for locked filters
* Fix provided filter names
* Fix navigating from instance browse to main browse
* Friends frontend (#2995)
* Friends system frontend
* (almost) finish frontend
* finish friends, fix lint
* Fix lint
---------
Signed-off-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
* Refresh macOS app icon
* Update web search UI more
* Fix link opens
* Fix frontend build
---------
Signed-off-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
Co-authored-by: Jai A <jaiagr+gpg@pm.me>
Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
2024-12-11 19:54:18 -08:00
|
|
|
|
|
|
|
|
export async function friend_listener(callback) {
|
|
|
|
|
return await listen('friend', (event) => callback(event.payload))
|
|
|
|
|
}
|