diff --git a/package-lock.json b/package-lock.json index c362829..5e927ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14233,7 +14233,7 @@ } }, "ui": { - "version": "0.4.2", + "version": "0.4.3", "dependencies": { "@fortawesome/free-solid-svg-icons": "^6.3.0", "@holochain-open-dev/elements": "0.400.0-dev.0", diff --git a/package.json b/package.json index a9ac644..b62cfce 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "package": "npm run build:happ && npm run package -w ui && hc web-app pack workdir --recursive", "build:happ": "npm run build:zomes && hc app pack workdir --recursive", "build:zomes": "CARGO_TARGET_DIR=target cargo build --release --target wasm32-unknown-unknown --workspace --exclude emergence-tauri", - "build:android": "npm run package && npm run tauri android build", + "build:android": "npm run package && npm run tauri android build --apk", "local-services": "hc run-local-services --bootstrap-interface $INTERNAL_IP --bootstrap-port $BOOTSTRAP_PORT --signal-interfaces $INTERNAL_IP --signal-port $SIGNAL_PORT", "tauri": "tauri" }, diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 1bb226f..49fb2d5 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -1953,7 +1953,7 @@ checksum = "4ef6b89e5b37196644d8796de5268852ff179b44e96276cf4290264843743bb7" [[package]] name = "emergence-tauri" -version = "0.0.0" +version = "0.4.3" dependencies = [ "anyhow", "app_dirs2", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index b3f2bfd..496602d 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "emergence-tauri" -version = "0.0.0" +version = "0.4.3" description = "Emergence" authors = ["you"] license = "" @@ -31,3 +31,10 @@ app_dirs2 = "2.5.5" tempdir = "0.3.7" anyhow = "1" uuid = "1" + +[profile.release] +strip = true +opt-level = "z" +lto = true +codegen-units = 1 +panic = "abort" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index e248a14..f94278a 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,9 +1,8 @@ { "productName": "emergence", - "version": "0.0.1", + "version": "0.4.3", "identifier": "org.holochain.emergence", "build": { - "beforeBuildCommand": "npm run build -w ui", "devUrl": "http://localhost:1420", "frontendDist": "../ui/dist" }, diff --git a/ui/package.json b/ui/package.json index 3a74655..b261898 100644 --- a/ui/package.json +++ b/ui/package.json @@ -1,6 +1,6 @@ { "name": "ui", - "version": "0.4.2", + "version": "0.4.3", "scripts": { "start": "vite --clearScreen false", "build": "vite build", diff --git a/ui/src/stores/clone-manager-store.ts b/ui/src/stores/clone-manager-store.ts index e3fa765..a3ec76c 100644 --- a/ui/src/stores/clone-manager-store.ts +++ b/ui/src/stores/clone-manager-store.ts @@ -7,6 +7,7 @@ import { CellType, type CellId, type ProvisionedCell, + type AppInfo, } from '@holochain/client'; import { get, writable, type Writable } from "svelte/store"; import { ProfilesClient, ProfilesStore } from '@holochain-open-dev/profiles'; @@ -44,17 +45,11 @@ export class CloneManagerStore { const appInfo = await this.client.appInfo(); if(!$activeDnaHash) { - await this._loadActiveDnaHash(); + await this._loadActiveDnaHash(appInfo); $activeDnaHash = get(this.activeDnaHash); } - const cellInfo = appInfo.cell_info[ROLE_NAME].find((cellInfo: CellInfo) => { - if(CellType.Provisioned in cellInfo) { - return hashEqual(cellInfo[CellType.Provisioned].cell_id[0], $activeDnaHash); - } else if(CellType.Cloned in cellInfo) { - return hashEqual(cellInfo[CellType.Cloned].cell_id[0], $activeDnaHash); - } - }); + const cellInfo = this._findCellInfoWithDnaHash(appInfo, $activeDnaHash); return this._makeCellInfoNormalized(appInfo.cell_info[ROLE_NAME][0][CellType.Provisioned], cellInfo) }); this.activeStore = asyncDerived([this.activeDnaHash, this.activeCellInfoNormalized], async ([$activeDnaHash, $activeCellInfoNormalized]) => { @@ -82,7 +77,6 @@ export class CloneManagerStore { return new EmergenceStore(this, emegenceClient, profilesStore, fileStorageClient, $activeDnaHash); }); - this._loadActiveDnaHash(); } async list(): Promise { @@ -127,15 +121,28 @@ export class CloneManagerStore { this.activeDnaHash.set(cellId[0]); } - private async _loadActiveDnaHash() { - const dnaHash = localStorage.getItem("activeDnaHash"); - if(dnaHash !== null && dnaHash !== undefined) { - this.activeDnaHash.set(decodeHashFromBase64(dnaHash)); - } else { - const appInfo = await this.client.appInfo(); - const defaultDnaHash = appInfo.cell_info[ROLE_NAME][0][CellType.Provisioned].cell_id[0]; - this.activeDnaHash.set(defaultDnaHash); + private async _loadActiveDnaHash(appInfo: AppInfo) { + // Load active dna hash from local storage + const activeDnaHashB64 = localStorage.getItem("activeDnaHash"); + + // Confirm that loaded dna hash is valid and cell exists + if(activeDnaHashB64 !== null && activeDnaHashB64 !== undefined) { + const activeDnaHash = decodeHashFromBase64(activeDnaHashB64); + const matchingCellInfo = this._findCellInfoWithDnaHash(appInfo, activeDnaHash); + + if(matchingCellInfo !== undefined) { + this.activeDnaHash.set(activeDnaHash); + return; + } } + + // Otherwise, set active dna hash to default + this._setDefaultActiveDnaHash(appInfo); + } + + private _setDefaultActiveDnaHash(appInfo: AppInfo) { + const defaultDnaHash = appInfo.cell_info[ROLE_NAME][0][CellType.Provisioned].cell_id[0]; + this.activeDnaHash.set(defaultDnaHash); } private _saveActiveDnaHash(val: DnaHash) { @@ -144,6 +151,18 @@ export class CloneManagerStore { } } + private _findCellInfoWithDnaHash(appInfo: AppInfo, dnaHash: Uint8Array): CellInfo | undefined { + const cellInfo = appInfo.cell_info[ROLE_NAME].find((cellInfo: CellInfo) => { + if(CellType.Provisioned in cellInfo) { + return hashEqual(cellInfo[CellType.Provisioned].cell_id[0], dnaHash); + } else if(CellType.Cloned in cellInfo) { + return hashEqual(cellInfo[CellType.Cloned].cell_id[0], dnaHash); + } + }); + + return cellInfo; + } + private _makeCellInfoNormalized(provisionedCellInfo: ProvisionedCell, cell: CellInfo ) { const originalDnaHash = provisionedCellInfo.cell_id[0];