Skip to content

Commit

Permalink
Changed examples
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed May 16, 2024
1 parent a80fbfd commit 6ba6235
Show file tree
Hide file tree
Showing 141 changed files with 13,112 additions and 5,440 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ pub fn run() {
},
))
.setup(|app| {
let handle = app.handle().clone();

app.holochain()?
.main_window_builder("main", true, None, None)?
.build()?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,7 @@
"security": {
"csp": null
},
"windows": [
{
"fullscreen": false,
"height": 600,
"resizable": true,
"title": "{{title_case runtime_name}}",
"width": 800
}
]
"windows": []
},
"bundle": {
"active": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ tauri-plugin-log = "2.0.0-beta"
url2 = "0.0.6"
app_dirs2 = "2.5.5"
tempdir = "0.3.7"

anyhow = "1"
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,10 @@ pub fn run() {
.setup(|app| {
let handle = app.handle().clone();
tauri::async_runtime::block_on(async move {
let mut admin_ws = handle.holochain()?.admin_websocket().await?;

let installed_apps = admin_ws
.list_apps(None)
.await
.map_err(|err| tauri_plugin_holochain::Error::ConductorApiError(err))?;

if installed_apps.len() == 0 {
handle
.holochain()?
.install_app(
String::from(APP_ID),
happ_bundle(),
HashMap::new(),
None,
)
.await
.map(|_| ())
} else {
// If the app bundle has changed, updated it
handle.holochain()?.update_app_if_necessary(
String::from(APP_ID),
happ_bundle()
).await?;
Ok(())
}
setup(handle).await
})?;

// After set up we can be sure our app is installed and up to date, so we can just open it
app.holochain()?
.main_window_builder("main", false, Some(String::from("{{app_name}}")), None)?
.build()?;
Expand All @@ -71,6 +47,44 @@ pub fn run() {
.expect("error while running tauri application");
}

// Very simple setup for now:
// - On app start, list installed apps:
// - If there are no apps installed, this is the first time the app is opened: install our hApp
// - If there **are** apps:
// - Check if it's necessary to update the coordinators for our hApp
// - And do so if it is
//
// You can modify this function to suit your needs if they become more complex
async fn setup(handle: AppHandle) -> anyhow::Result<()> {
let mut admin_ws = handle.holochain()?.admin_websocket().await?;

let installed_apps = admin_ws
.list_apps(None)
.await
.map_err(|err| tauri_plugin_holochain::Error::ConductorApiError(err))?;

if installed_apps.len() == 0 {
handle
.holochain()?
.install_app(
String::from(APP_ID),
happ_bundle()
HashMap::new(),
None,
)
.await?;

Ok(())
} else {
handle.holochain()?.update_app_if_necessary(
String::from(APP_ID),
happ_bundle()
).await?;

Ok(())
}
}

fn internal_ip() -> String {
if cfg!(mobile) {
std::option_env!("INTERNAL_IP")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,7 @@
"security": {
"csp": null
},
"windows": [
{
"fullscreen": false,
"height": 600,
"resizable": true,
"title": "{{title_case app_name}}",
"width": 800
}
]
"windows": []
},
"bundle": {
"active": true,
Expand Down
File renamed without changes.
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ tauri-plugin-log = "2.0.0-beta"
url2 = "0.0.6"
app_dirs2 = "2.5.5"
tempdir = "0.3.7"

anyhow = "1"
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::collections::HashMap;
use std::path::PathBuf;
use tauri_plugin_holochain::{HolochainExt, HolochainPluginConfig};
use url2::Url2;
use tauri::AppHandle;

const APP_ID: &'static str = "example";

Expand Down Expand Up @@ -105,32 +106,7 @@ pub fn run() {
.setup(|app| {
let handle = app.handle().clone();
tauri::async_runtime::block_on(async move {
let mut admin_ws = handle.holochain()?.admin_websocket().await?;

let installed_apps = admin_ws
.list_apps(None)
.await
.map_err(|err| tauri_plugin_holochain::Error::ConductorApiError(err))?;

if installed_apps.len() == 0 {
handle
.holochain()?
.install_app(
String::from(APP_ID),
example_happ(),
HashMap::new(),
None,
)
.await
.map(|_| ())
} else {
handle.holochain()?.update_app_if_necessary(
String::from(APP_ID),
example_happ()
).await.map(|_| ())?;

Ok(())
}
setup(handle).await
})?;

app.holochain()?
Expand All @@ -142,3 +118,41 @@ pub fn run() {
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

// Very simple setup for now:
// - On app start, list installed apps:
// - If there are no apps installed, this is the first time the app is opened: install our hApp
// - If there **are** apps:
// - Check if it's necessary to update the coordinators for our hApp
// - And do so if it is
//
// You can modify this function to suit your needs if they become more complex
async fn setup(handle: AppHandle) -> anyhow::Result<()> {
let mut admin_ws = handle.holochain()?.admin_websocket().await?;

let installed_apps = admin_ws
.list_apps(None)
.await
.map_err(|err| tauri_plugin_holochain::Error::ConductorApiError(err))?;

if installed_apps.len() == 0 {
handle
.holochain()?
.install_app(
String::from(APP_ID),
example_happ(),
HashMap::new(),
None,
)
.await?;

Ok(())
} else {
handle.holochain()?.update_app_if_necessary(
String::from(APP_ID),
example_happ()
).await?;

Ok(())
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions examples/holochain-runtime/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Launcher
Loading

0 comments on commit 6ba6235

Please sign in to comment.