Skip to content

Commit

Permalink
Merge pull request #43 from holochain-apps/release/v0.4.3
Browse files Browse the repository at this point in the history
Release/v0.4.3
  • Loading branch information
mattyg authored Aug 7, 2024
2 parents 160da35 + 3b70330 commit 1f184cf
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

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

9 changes: 8 additions & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "emergence-tauri"
version = "0.0.0"
version = "0.4.3"
description = "Emergence"
authors = ["you"]
license = ""
Expand Down Expand Up @@ -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"
3 changes: 1 addition & 2 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ui",
"version": "0.4.2",
"version": "0.4.3",
"scripts": {
"start": "vite --clearScreen false",
"build": "vite build",
Expand Down
53 changes: 36 additions & 17 deletions ui/src/stores/clone-manager-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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]) => {
Expand Down Expand Up @@ -82,7 +77,6 @@ export class CloneManagerStore {

return new EmergenceStore(this, emegenceClient, profilesStore, fileStorageClient, $activeDnaHash);
});
this._loadActiveDnaHash();
}

async list(): Promise<CellInfoNormalized[]> {
Expand Down Expand Up @@ -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) {
Expand All @@ -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];

Expand Down

0 comments on commit 1f184cf

Please sign in to comment.