From a4731cf3c007d2cb354442f64e35a56c6a515369 Mon Sep 17 00:00:00 2001 From: "guillem.cordoba" Date: Wed, 8 May 2024 12:58:14 +0200 Subject: [PATCH] Fixed search-agent --- flake.lock | 112 +++++----- flake.nix | 86 ++++---- package-lock.json | 16 +- package.json | 57 +++--- ui/demo/index.html | 250 +++++++++++------------ ui/package.json | 2 +- ui/src/elements/search-agent-dropdown.ts | 29 +-- ui/src/profiles-client.ts | 132 ++++++------ 8 files changed, 328 insertions(+), 356 deletions(-) diff --git a/flake.lock b/flake.lock index 667786018..54262f61e 100644 --- a/flake.lock +++ b/flake.lock @@ -73,11 +73,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1713979152, - "narHash": "sha256-apdecPuh8SOQnkEET/kW/UcfjCRb8JbV5BKjoH+DcP4=", + "lastModified": 1714864355, + "narHash": "sha256-uXNW6bapWFfkYIkK1EagydSrFMqycOYEDSq75GmUpjk=", "owner": "ipetkov", "repo": "crane", - "rev": "a5eca68a2cf11adb32787fc141cddd29ac8eb79c", + "rev": "442a7a6152f49b907e73206dc8e1f46a61e8e873", "type": "github" }, "original": { @@ -326,11 +326,11 @@ "versions": "versions" }, "locked": { - "lastModified": 1714396487, - "narHash": "sha256-NhtToT3aNno1YXjczEIxVvGc9cXfB1amtYDchUnWL6Y=", + "lastModified": 1715079199, + "narHash": "sha256-x4SQ5u6KumRhIaNAkigBYWgvHTR9sPYKsi68iebFisU=", "owner": "holochain-open-dev", "repo": "infrastructure", - "rev": "6c0acb8a777719a49458126023e324c319ebc119", + "rev": "2ddc14df21e42cb3cb9a5d832eb0f13fa0267fc2", "type": "github" }, "original": { @@ -379,11 +379,11 @@ ] }, "locked": { - "lastModified": 1714389570, - "narHash": "sha256-qnbAGp3hu1IlegoHtstS6UObUFR7SZQOnxyeZcCStXs=", + "lastModified": 1714997624, + "narHash": "sha256-eCM6JEukjMdjFwjBm/FEKRUvBZIzGYE0gP71EWHs4lE=", "owner": "holochain", "repo": "holochain", - "rev": "b2c2de05036d4705cc29f639cabe33accb814039", + "rev": "993e875c10204870644a73125d63fb13b1f1070b", "type": "github" }, "original": { @@ -444,11 +444,11 @@ ] }, "locked": { - "lastModified": 1714408217, - "narHash": "sha256-lc93HR/e9Eth+KdQk0NCBeneK25AtQrUB4XB0/HoBNQ=", + "lastModified": 1715075584, + "narHash": "sha256-AZbckXdtu526rjCP+CNhLBmPFs2tKVwfvhvmKBDuH4c=", "owner": "holochain", "repo": "holochain", - "rev": "8a2c00958dabd1fb0a9dd109c67341f3526c1479", + "rev": "de729662e1d0812ef008bf56fde2c0cfcc3c5232", "type": "github" }, "original": { @@ -511,16 +511,16 @@ "launcher": { "flake": false, "locked": { - "lastModified": 1714385528, - "narHash": "sha256-3ZGDC9zx/bqOgYOdImq6yWfZsbxx+B8yzzD8zsztG1U=", + "lastModified": 1714396970, + "narHash": "sha256-I/Vpxtg8cwhrrD5JugEgE4Qk8fZR6VewGm5FX69vbm0=", "owner": "holochain", "repo": "launcher", - "rev": "afe234041e27c1d8486bfaa4af270a033e9a1c9f", + "rev": "b96d5aa790bf0da0a8f0c44741276f7f9c4b6b41", "type": "github" }, "original": { "owner": "holochain", - "ref": "holochain-weekly", + "ref": "holochain-0.3", "repo": "launcher", "type": "github" } @@ -528,16 +528,16 @@ "launcher_2": { "flake": false, "locked": { - "lastModified": 1714385528, - "narHash": "sha256-3ZGDC9zx/bqOgYOdImq6yWfZsbxx+B8yzzD8zsztG1U=", + "lastModified": 1714396970, + "narHash": "sha256-I/Vpxtg8cwhrrD5JugEgE4Qk8fZR6VewGm5FX69vbm0=", "owner": "holochain", "repo": "launcher", - "rev": "afe234041e27c1d8486bfaa4af270a033e9a1c9f", + "rev": "b96d5aa790bf0da0a8f0c44741276f7f9c4b6b41", "type": "github" }, "original": { "owner": "holochain", - "ref": "holochain-weekly", + "ref": "holochain-0.3", "repo": "launcher", "type": "github" } @@ -574,11 +574,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1713349283, - "narHash": "sha256-2bjFu3+1zPWZPPGqF+7rumTvEwmdBHBhjPva/AMSruQ=", + "lastModified": 1714656196, + "narHash": "sha256-kjQkA98lMcsom6Gbhw8SYzmwrSo+2nruiTcTZp5jK7o=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2e359fb3162c85095409071d131e08252d91a14f", + "rev": "94035b482d181af0a0f8f77823a790b256b7c3cc", "type": "github" }, "original": { @@ -626,11 +626,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1714253743, - "narHash": "sha256-mdTQw2XlariysyScCv2tTE45QSU9v/ezLcHJ22f0Nxc=", + "lastModified": 1714906307, + "narHash": "sha256-UlRZtrCnhPFSJlDQE7M0eyhgvuuHBTe1eJ9N9AQlJQ0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "58a1abdbae3217ca6b702f03d3b35125d88a2994", + "rev": "25865a40d14b3f9cf19f19b924e2ab4069b09588", "type": "github" }, "original": { @@ -641,11 +641,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1714253743, - "narHash": "sha256-mdTQw2XlariysyScCv2tTE45QSU9v/ezLcHJ22f0Nxc=", + "lastModified": 1714906307, + "narHash": "sha256-UlRZtrCnhPFSJlDQE7M0eyhgvuuHBTe1eJ9N9AQlJQ0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "58a1abdbae3217ca6b702f03d3b35125d88a2994", + "rev": "25865a40d14b3f9cf19f19b924e2ab4069b09588", "type": "github" }, "original": { @@ -731,11 +731,11 @@ ] }, "locked": { - "lastModified": 1714356894, - "narHash": "sha256-W6Mss7AG6bnFT1BqRApHXvLXBrFOu7V0+EUe9iML30s=", + "lastModified": 1714961776, + "narHash": "sha256-LiIxWRKbm1DZ+7l1a6FMmIO8leQx5yrRLIApCMai1DY=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "d9b44509b4064f0a3fc9c7c92a603861f52fbedc", + "rev": "f3b20ea4131408ea585bddb1f41f91c4de9499cf", "type": "github" }, "original": { @@ -753,11 +753,11 @@ ] }, "locked": { - "lastModified": 1714356894, - "narHash": "sha256-W6Mss7AG6bnFT1BqRApHXvLXBrFOu7V0+EUe9iML30s=", + "lastModified": 1714961776, + "narHash": "sha256-LiIxWRKbm1DZ+7l1a6FMmIO8leQx5yrRLIApCMai1DY=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "d9b44509b4064f0a3fc9c7c92a603861f52fbedc", + "rev": "f3b20ea4131408ea585bddb1f41f91c4de9499cf", "type": "github" }, "original": { @@ -775,11 +775,11 @@ ] }, "locked": { - "lastModified": 1714356894, - "narHash": "sha256-W6Mss7AG6bnFT1BqRApHXvLXBrFOu7V0+EUe9iML30s=", + "lastModified": 1715048276, + "narHash": "sha256-SqWSTvCjNBBnV/WIQdaxVi5V9H3VJ7cOJAxPQdR1TBY=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "d9b44509b4064f0a3fc9c7c92a603861f52fbedc", + "rev": "b037d65c988421b54024e62691eace4f2fe623bc", "type": "github" }, "original": { @@ -791,16 +791,16 @@ "scaffolding": { "flake": false, "locked": { - "lastModified": 1713363855, - "narHash": "sha256-Y9KsDAjlZZab07NL7pI1izxLOYT4BWYTx1h9DilW8Fk=", + "lastModified": 1714147981, + "narHash": "sha256-PIWouOg4W2jVFjsHexAqOCdnwy6gQgll7kWRHssiid0=", "owner": "holochain", "repo": "scaffolding", - "rev": "9ac485d52122b92bd2988a8fea1a8e4d9a18c3a1", + "rev": "6582621e73b5127ed863b13f5648d9a333542623", "type": "github" }, "original": { "owner": "holochain", - "ref": "holochain-weekly", + "ref": "holochain-0.3", "repo": "scaffolding", "type": "github" } @@ -808,16 +808,16 @@ "scaffolding_2": { "flake": false, "locked": { - "lastModified": 1713363855, - "narHash": "sha256-Y9KsDAjlZZab07NL7pI1izxLOYT4BWYTx1h9DilW8Fk=", + "lastModified": 1714147981, + "narHash": "sha256-PIWouOg4W2jVFjsHexAqOCdnwy6gQgll7kWRHssiid0=", "owner": "holochain", "repo": "scaffolding", - "rev": "9ac485d52122b92bd2988a8fea1a8e4d9a18c3a1", + "rev": "6582621e73b5127ed863b13f5648d9a333542623", "type": "github" }, "original": { "owner": "holochain", - "ref": "holochain-weekly", + "ref": "holochain-0.3", "repo": "scaffolding", "type": "github" } @@ -875,16 +875,16 @@ "scaffolding": "scaffolding" }, "locked": { - "dir": "versions/weekly", - "lastModified": 1714389570, - "narHash": "sha256-qnbAGp3hu1IlegoHtstS6UObUFR7SZQOnxyeZcCStXs=", + "dir": "versions/0_3_rc", + "lastModified": 1714997624, + "narHash": "sha256-eCM6JEukjMdjFwjBm/FEKRUvBZIzGYE0gP71EWHs4lE=", "owner": "holochain", "repo": "holochain", - "rev": "b2c2de05036d4705cc29f639cabe33accb814039", + "rev": "993e875c10204870644a73125d63fb13b1f1070b", "type": "github" }, "original": { - "dir": "versions/weekly", + "dir": "versions/0_3_rc", "owner": "holochain", "repo": "holochain", "type": "github" @@ -898,16 +898,16 @@ "scaffolding": "scaffolding_2" }, "locked": { - "dir": "versions/weekly", - "lastModified": 1714408217, - "narHash": "sha256-lc93HR/e9Eth+KdQk0NCBeneK25AtQrUB4XB0/HoBNQ=", + "dir": "versions/0_3_rc", + "lastModified": 1715075584, + "narHash": "sha256-AZbckXdtu526rjCP+CNhLBmPFs2tKVwfvhvmKBDuH4c=", "owner": "holochain", "repo": "holochain", - "rev": "8a2c00958dabd1fb0a9dd109c67341f3526c1479", + "rev": "de729662e1d0812ef008bf56fde2c0cfcc3c5232", "type": "github" }, "original": { - "dir": "versions/weekly", + "dir": "versions/0_3_rc", "owner": "holochain", "repo": "holochain", "type": "github" diff --git a/flake.nix b/flake.nix index 95f3e43e3..a3837c99f 100644 --- a/flake.nix +++ b/flake.nix @@ -1,10 +1,10 @@ { description = "Template for Holochain app development"; - + inputs = { nixpkgs.follows = "holochain/nixpkgs"; - versions.url = "github:holochain/holochain?dir=versions/weekly"; + versions.url = "github:holochain/holochain?dir=versions/0_3_rc"; holochain = { url = "github:holochain/holochain"; @@ -14,57 +14,41 @@ }; nixConfig = { - extra-substituters = [ - "https://holochain-open-dev.cachix.org" - ]; - extra-trusted-public-keys = [ - "holochain-open-dev.cachix.org-1:3Tr+9in6uo44Ga7qiuRIfOTFXog+2+YbyhwI/Z6Cp4U=" - ]; - }; + extra-substituters = [ "https://holochain-open-dev.cachix.org" ]; + extra-trusted-public-keys = [ + "holochain-open-dev.cachix.org-1:3Tr+9in6uo44Ga7qiuRIfOTFXog+2+YbyhwI/Z6Cp4U=" + ]; + }; - outputs = inputs @ { ... }: - inputs.holochain.inputs.flake-parts.lib.mkFlake - { - inherit inputs; - specialArgs.rootPath = ./.; - } - { - imports = [ - ./crates/coordinator/zome.nix - ./crates/integrity/zome.nix - ]; + outputs = inputs@{ ... }: + inputs.holochain.inputs.flake-parts.lib.mkFlake { + inherit inputs; + specialArgs.rootPath = ./.; + } { + imports = [ ./crates/coordinator/zome.nix ./crates/integrity/zome.nix ]; - systems = builtins.attrNames inputs.holochain.devShells; - perSystem = - { inputs' - , config - , pkgs - , system - , lib - , ... - }: { - devShells.default = pkgs.mkShell { - inputsFrom = [ inputs'.holochain.devShells.holonix ]; - packages = with pkgs; [ - nodejs_20 - ]; - }; + systems = builtins.attrNames inputs.holochain.devShells; + perSystem = { inputs', config, pkgs, system, lib, ... }: { + devShells.default = pkgs.mkShell { + inputsFrom = [ inputs'.holochain.devShells.holonix ]; + packages = with pkgs; [ nodejs_20 ]; + }; - packages.scaffold = pkgs.symlinkJoin { - name = "scaffold-remote-zome"; - paths = [ inputs'.hc-infra.packages.scaffold-remote-zome ]; - buildInputs = [ pkgs.makeWrapper ]; - postBuild = '' - wrapProgram $out/bin/scaffold-remote-zome \ - --add-flags "profiles \ - --integrity-zome-name profiles_integrity \ - --coordinator-zome-name profiles \ - --remote-zome-git-url github:holochain-open-dev/profiles \ - --remote-zome-git-branch nixify \ - --remote-npm-package-name @holochain-open-dev/profiles \ - --remote-npm-package-path ui" - ''; - }; - }; + packages.scaffold = pkgs.symlinkJoin { + name = "scaffold-remote-zome"; + paths = [ inputs'.hc-infra.packages.scaffold-remote-zome ]; + buildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + wrapProgram $out/bin/scaffold-remote-zome \ + --add-flags "profiles \ + --integrity-zome-name profiles_integrity \ + --coordinator-zome-name profiles \ + --remote-zome-git-url github:holochain-open-dev/profiles \ + --remote-zome-git-branch nixify \ + --remote-npm-package-name @holochain-open-dev/profiles \ + --remote-npm-package-path ui" + ''; + }; }; + }; } diff --git a/package-lock.json b/package-lock.json index c32563aa7..5e8781887 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1345,14 +1345,14 @@ "link": true }, "node_modules/@holochain-open-dev/signals": { - "version": "0.300.0-dev.7", - "resolved": "https://registry.npmjs.org/@holochain-open-dev/signals/-/signals-0.300.0-dev.7.tgz", - "integrity": "sha512-DG1dTbWeGjnqu9Q5vFLChAZE3gVUsL5PBHMEuKc0f32bfe8BrPvNsk4QOwtmvVHUDsS6okYph/p4/hOLqsN+5g==", + "version": "0.300.0-dev.8", + "resolved": "https://registry.npmjs.org/@holochain-open-dev/signals/-/signals-0.300.0-dev.8.tgz", + "integrity": "sha512-09ECGESEfw4kjSBwZd7+ETaZD+bOZLrM0ihh6BdMpvdpPPJLSfC9zX7RD++d7xBrAla30GVMMkrYbzmL/BQbyA==", "dependencies": { "@holochain-open-dev/utils": "^0.300.0-dev.2", "@holochain/client": "^0.17.0-dev.12", "@shoelace-style/shoelace": "^2.11.2", - "async-signals": "^0.1.7", + "async-signals": "^0.1.8", "lit-signal-watcher": "^0.1.0", "signal-polyfill": "^0.1.0" } @@ -3128,9 +3128,9 @@ } }, "node_modules/async-signals": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/async-signals/-/async-signals-0.1.7.tgz", - "integrity": "sha512-4P9JU/yw20g1KYHB1jGwTDInwlirvQSe8FlGy4L17WvI1saQiLVfv19C6pyCFcNejaOvxYPams9F0rR/vy+Q8A==", + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/async-signals/-/async-signals-0.1.8.tgz", + "integrity": "sha512-lZazlln01HUmdNvSz76bkBfU+6RB6HwrsBpMNK4w0YEnolvCFah+2/LdSC8/eW2iSCj95PsJgpTLnAlxwKeqrw==", "dependencies": { "lit": "^3.0.0", "signal-polyfill": "^0.1.0" @@ -9590,7 +9590,7 @@ "license": "MIT", "dependencies": { "@holochain-open-dev/elements": "^0.300.0-dev.1", - "@holochain-open-dev/signals": "^0.300.0-dev.7", + "@holochain-open-dev/signals": "^0.300.0-dev.8", "@holochain-open-dev/utils": "^0.300.0-dev.2", "@holochain/client": "^0.17.0-dev.12", "@lit/context": "^1.0.1", diff --git a/package.json b/package.json index 99943aaef..4acbc4200 100644 --- a/package.json +++ b/package.json @@ -1,31 +1,30 @@ { - "name": "@holochain-open-dev/profiles-dev", - "private": true, - "workspaces": ["ui", "tests", "docs"], - "scripts": { - "start": "AGENTS=2 npm run network", - "network": "hc s clean && npm run build:happ && BOOTSTRAP_PORT=$(port) SIGNAL_PORT=$(port) UI_PORT=8888 concurrently \"npm start -w ui\" \"npm run local-services\" \"npm run launch\" \"holochain-playground\"", - "test": "npm run build:happ && nix flake check -L && npm test -w tests", - "launch": "echo pass | RUST_LOG=warn hc launch --piped -n $AGENTS workdir/profiles-test.happ --ui-port $UI_PORT network --bootstrap http://127.0.0.1:$BOOTSTRAP_PORT webrtc ws://127.0.0.1:$SIGNAL_PORT", - "local-services": "hc run-local-services --bootstrap-port $BOOTSTRAP_PORT --signal-port $SIGNAL_PORT", - "build:happ": "npm run build:zome && hc app pack workdir --recursive", - "build:zome": "CARGO_TARGET_DIR=target cargo build --release --target wasm32-unknown-unknown", - "docs:start": "npm run docs:setup && storybook dev -p 6006", - "docs:publish": "npm run docs:setup && storybook build && gh-pages -d ./storybook-static -b gh-pages", - "docs:setup": "npm run build -w @holochain-open-dev/profiles && npm run analyze -w @holochain-open-dev/profiles" - }, - "devDependencies": { - "@holochain-playground/cli": "^0.1.0", - "@trivago/prettier-plugin-sort-imports": "^4.3.0", - "@eslint/js": "^8.0.0", - "concurrently": "^6.2.1", - "eslint": "^8.0.0", - "eslint-config-prettier": "^9.1.0", - "gh-pages": "^3.2.3", - "new-port-cli": "^1.0.0", - "prettier": "^3.2.5", - "typescript-eslint": "^7.7.0", - "typescript": "^5.4.5" - }, - "type": "module" + "name": "@holochain-open-dev/profiles-dev", + "private": true, + "workspaces": ["ui", "tests", "docs"], + "scripts": { + "start": "AGENTS=2 npm run network", + "network": "hc s clean && npm run build:happ && BOOTSTRAP_PORT=$(port) SIGNAL_PORT=$(port) UI_PORT=8888 concurrently \"npm start -w ui\" \"npm run local-services\" \"npm run launch\" \"holochain-playground\"", + "test": "npm run build:happ && nix flake check -L && npm test -w tests", + "launch": "echo pass | RUST_LOG=warn hc launch --piped -n $AGENTS workdir/profiles-test.happ --ui-port $UI_PORT network --bootstrap http://127.0.0.1:$BOOTSTRAP_PORT webrtc ws://127.0.0.1:$SIGNAL_PORT", + "local-services": "hc run-local-services --bootstrap-port $BOOTSTRAP_PORT --signal-port $SIGNAL_PORT", + "build:happ": "npm run build:zome && hc app pack workdir --recursive", + "build:zome": "CARGO_TARGET_DIR=target cargo build --release --target wasm32-unknown-unknown", + "docs:start": "npm run docs:setup && storybook dev -p 6006", + "docs:publish": "npm run docs:setup && storybook build && gh-pages -d ./storybook-static -b gh-pages", + "docs:setup": "npm run build -w @holochain-open-dev/profiles && npm run analyze -w @holochain-open-dev/profiles" + }, + "devDependencies": { + "@holochain-playground/cli": "^0.1.0", + "@trivago/prettier-plugin-sort-imports": "^4.3.0", + "@eslint/js": "^8.0.0", + "concurrently": "^6.2.1", + "eslint": "^8.0.0", + "eslint-config-prettier": "^9.1.0", + "new-port-cli": "^1.0.0", + "prettier": "^3.2.5", + "typescript-eslint": "^7.7.0", + "typescript": "^5.4.5" + }, + "type": "module" } diff --git a/ui/demo/index.html b/ui/demo/index.html index af9c8f23c..3af359ab9 100644 --- a/ui/demo/index.html +++ b/ui/demo/index.html @@ -1,137 +1,135 @@ - + - - - - - - + + + + + + - - + customElements.define('profiles-test', ProfilesTest); + + diff --git a/ui/package.json b/ui/package.json index 1b1ecf9a7..f3f638f36 100644 --- a/ui/package.json +++ b/ui/package.json @@ -28,7 +28,7 @@ }, "dependencies": { "@holochain-open-dev/elements": "^0.300.0-dev.1", - "@holochain-open-dev/signals": "^0.300.0-dev.7", + "@holochain-open-dev/signals": "^0.300.0-dev.8", "@holochain-open-dev/utils": "^0.300.0-dev.2", "@holochain/client": "^0.17.0-dev.12", "@lit/context": "^1.0.1", diff --git a/ui/src/elements/search-agent-dropdown.ts b/ui/src/elements/search-agent-dropdown.ts index 3cfa4e499..39cf06e3c 100644 --- a/ui/src/elements/search-agent-dropdown.ts +++ b/ui/src/elements/search-agent-dropdown.ts @@ -4,8 +4,8 @@ import { AsyncComputed, Signal, SignalWatcher, - fromPromise, joinAsyncMap, + pipe, toPromise, } from '@holochain-open-dev/signals'; import { @@ -74,25 +74,14 @@ export class SearchAgentDropdown extends SignalWatcher(LitElement) { /** * @internal */ - _searchProfiles$ = new AsyncComputed(() => { - const filter = this.searchFilter$.get(); - if (!filter || filter.length < 3) - return { - status: 'completed', - value: new HoloHashMap() as ReadonlyMap< - AgentPubKey, - EntryRecord | undefined - >, - }; - - const agents = fromPromise(() => - this.store.client.searchAgents(filter), - ).get(); - if (agents.status !== 'completed') return agents; - - const profiles = slice(this.store.profiles, agents.value); - return joinAsyncMap(mapValues(profiles, p => p.get())); - }); + _searchProfiles$ = pipe( + this.searchFilter$, + filter => this.store.client.searchAgents(filter!), + agents => { + const profiles = slice(this.store.profiles, agents); + return joinAsyncMap(mapValues(profiles, p => p.get())); + }, + ); /** * @internal diff --git a/ui/src/profiles-client.ts b/ui/src/profiles-client.ts index 7e765c5e5..4be820680 100644 --- a/ui/src/profiles-client.ts +++ b/ui/src/profiles-client.ts @@ -1,75 +1,77 @@ -import { EntryRecord, ZomeClient } from "@holochain-open-dev/utils"; +import { EntryRecord, ZomeClient } from '@holochain-open-dev/utils'; import { - AgentPubKey, - Record, - AppClient, - RoleName, - Link, -} from "@holochain/client"; -import { Profile, ProfilesSignal } from "./types"; + AgentPubKey, + AppClient, + Link, + Record, + RoleName, +} from '@holochain/client'; + +import { Profile, ProfilesSignal } from './types'; export class ProfilesClient extends ZomeClient { - constructor( - public client: AppClient, - public roleName: RoleName, - public zomeName = "profiles" - ) { - super(client as any, roleName, zomeName); - } + constructor( + public client: AppClient, + public roleName: RoleName, + public zomeName = 'profiles', + ) { + super(client as any, roleName, zomeName); + } - /** - * Get the profile for the given agent, if they have created it - * - * @param agentPubKey the agent to get the profile for - * @returns the profile of the agent, if they have created one - */ - async getAgentProfile( - agentPubKey: AgentPubKey - ): Promise | undefined> { - const record: Record | undefined = await this.callZome( - "get_agent_profile", - agentPubKey - ); + /** + * Get the profile for the given agent, if they have created it + * + * @param agentPubKey the agent to get the profile for + * @returns the profile of the agent, if they have created one + */ + async getAgentProfile( + agentPubKey: AgentPubKey, + ): Promise | undefined> { + const record: Record | undefined = await this.callZome( + 'get_agent_profile', + agentPubKey, + ); - return record ? new EntryRecord(record) : undefined; - } + return record ? new EntryRecord(record) : undefined; + } - /** - * Search profiles that start with nicknameFilter - * - * @param nicknameFilter must be of at least 3 characters - * @returns the agents with the nickname starting with nicknameFilter - */ - async searchAgents(nicknameFilter: string): Promise { - return this.callZome("search_agents", nicknameFilter); - } + /** + * Search profiles that start with nicknameFilter + * + * @param nicknameFilter must be of at least 3 characters + * @returns the agents with the nickname starting with nicknameFilter + */ + async searchAgents(nicknameFilter: string): Promise { + console.log('searchagents', nicknameFilter); + return this.callZome('search_agents', nicknameFilter); + } - /** - * Get all the agents in the DHT that have created a profile - * - * @returns the agent public keys of all agents that have created a profile - */ - async getAgentsWithProfile(): Promise { - return this.callZome("get_agents_with_profile", null); - } + /** + * Get all the agents in the DHT that have created a profile + * + * @returns the agent public keys of all agents that have created a profile + */ + async getAgentsWithProfile(): Promise { + return this.callZome('get_agents_with_profile', null); + } - /** - * Create my profile - * - * @param profile the profile to create - */ - async createProfile(profile: Profile): Promise> { - const record: Record = await this.callZome("create_profile", profile); - return new EntryRecord(record); - } + /** + * Create my profile + * + * @param profile the profile to create + */ + async createProfile(profile: Profile): Promise> { + const record: Record = await this.callZome('create_profile', profile); + return new EntryRecord(record); + } - /** - * Update my profile - * - * @param profile the profile to create - */ - async updateProfile(profile: Profile): Promise> { - const record: Record = await this.callZome("update_profile", profile); - return new EntryRecord(record); - } + /** + * Update my profile + * + * @param profile the profile to create + */ + async updateProfile(profile: Profile): Promise> { + const record: Record = await this.callZome('update_profile', profile); + return new EntryRecord(record); + } }