From c0b5dacc4c108428aa5569874ec24320f9fbb7b9 Mon Sep 17 00:00:00 2001 From: "guillem.cordoba" Date: Mon, 2 Dec 2024 13:29:50 +0100 Subject: [PATCH 1/4] Link --- ui/package.json | 9 +++------ ui/src/elements/show-avatar-image.ts | 2 +- ui/src/elements/upload-avatar.ts | 6 +++--- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/ui/package.json b/ui/package.json index 5207740..220cbe1 100644 --- a/ui/package.json +++ b/ui/package.json @@ -10,13 +10,10 @@ ".": "./dist/index.js", "./dist/*": "./dist/*" }, - "files": [ - "dist", - "src" - ], + "files": ["dist", "src"], "scripts": { "start": "vite --clearScreen false --port $UI_PORT", - "build": "npm run lint && tsc", + "build": "pnpm lint && tsc", "lint": "eslint --ext .ts,.html src --ignore-path .gitignore", "analyze": "cem analyze --litelement --exclude dist", "format": "eslint --ext .ts,.html src --fix --ignore-path .gitignore", @@ -62,4 +59,4 @@ }, "customElements": "custom-elements.json", "type": "module" -} \ No newline at end of file +} diff --git a/ui/src/elements/show-avatar-image.ts b/ui/src/elements/show-avatar-image.ts index b367e0c..df298cd 100644 --- a/ui/src/elements/show-avatar-image.ts +++ b/ui/src/elements/show-avatar-image.ts @@ -36,7 +36,7 @@ export class ShowAvatarImage extends LitElement { client!: FileStorageClient; @property() - initials: string = ""; + initials = ""; /** * @internal diff --git a/ui/src/elements/upload-avatar.ts b/ui/src/elements/upload-avatar.ts index 9ddb34b..44c439a 100644 --- a/ui/src/elements/upload-avatar.ts +++ b/ui/src/elements/upload-avatar.ts @@ -20,10 +20,10 @@ import "./show-avatar-image.js"; @customElement("upload-avatar") export class UploadAvatar extends LitElement implements FormField { @property({ attribute: "name" }) - name: string = "avatar"; + name = "avatar"; @property() - required: boolean = false; + required = false; @property() shape: "circle" | "square" | "rounded" = "circle"; @@ -32,7 +32,7 @@ export class UploadAvatar extends LitElement implements FormField { value: EntryHash | undefined; @property() - disabled: boolean = false; + disabled = false; @property() defaultValue: EntryHash | undefined; From c7a8cc0918eb77b3afde5204a41e75867eae7d6b Mon Sep 17 00:00:00 2001 From: "guillem.cordoba" Date: Mon, 2 Dec 2024 13:30:15 +0100 Subject: [PATCH 2/4] pnpm --- .github/workflows/build-and-cache.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-cache.yml b/.github/workflows/build-and-cache.yml index 7c0074b..8d7f66e 100644 --- a/.github/workflows/build-and-cache.yml +++ b/.github/workflows/build-and-cache.yml @@ -31,7 +31,7 @@ jobs: - name: Install and test run: | - nix develop --no-update-lock-file --accept-flake-config --command bash -c "npm i && npm t && npm run -w @darksoil-studio/file-storage-zome build" + nix develop --no-update-lock-file --accept-flake-config --command bash -c "pnpm i && pnpm t && pnpm -F @darksoil-studio/file-storage-zome build" - name: Install jq uses: dcarbone/install-jq-action@v2.1.0 From abea6a85c563fdf72d7c882fde048401aec9dced Mon Sep 17 00:00:00 2001 From: "guillem.cordoba" Date: Mon, 2 Dec 2024 13:32:48 +0100 Subject: [PATCH 3/4] Lock --- pnpm-lock.yaml | 6 +++--- ui/package.json | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 16139fb..33f4925 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -89,6 +89,9 @@ importers: '@lit/localize': specifier: ^0.12.0 version: 0.12.2 + '@mdi/js': + specifier: ^7.4.47 + version: 7.4.47 '@scoped-elements/dropzone': specifier: ^0.2.1 version: 0.2.7(@types/react@18.3.12) @@ -114,9 +117,6 @@ importers: '@custom-elements-manifest/analyzer': specifier: ^0.5.7 version: 0.5.7 - '@mdi/js': - specifier: ^7.4.47 - version: 7.4.47 '@open-wc/eslint-config': specifier: ^2.0.0 version: 2.1.0(eslint-plugin-babel@5.3.1(eslint@7.32.0))(eslint-plugin-html@6.2.0)(eslint-plugin-import@2.31.0(@typescript-eslint/parser@5.62.0(eslint@7.32.0)(typescript@5.6.3))(eslint@7.32.0))(eslint-plugin-lit@1.15.0(eslint@7.32.0))(eslint-plugin-no-only-tests@2.6.0)(eslint-plugin-wc@1.5.0(eslint@7.32.0)) diff --git a/ui/package.json b/ui/package.json index 220cbe1..611e038 100644 --- a/ui/package.json +++ b/ui/package.json @@ -10,7 +10,10 @@ ".": "./dist/index.js", "./dist/*": "./dist/*" }, - "files": ["dist", "src"], + "files": [ + "dist", + "src" + ], "scripts": { "start": "vite --clearScreen false --port $UI_PORT", "build": "pnpm lint && tsc", @@ -59,4 +62,4 @@ }, "customElements": "custom-elements.json", "type": "module" -} +} \ No newline at end of file From 72f1f6fbcb0c1e524058e88247a01b16080b7a7f Mon Sep 17 00:00:00 2001 From: "guillem.cordoba" Date: Tue, 3 Dec 2024 18:23:03 +0100 Subject: [PATCH 4/4] Fixed show-avatar-image --- ui/src/elements/show-avatar-image.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ui/src/elements/show-avatar-image.ts b/ui/src/elements/show-avatar-image.ts index df298cd..7418cfd 100644 --- a/ui/src/elements/show-avatar-image.ts +++ b/ui/src/elements/show-avatar-image.ts @@ -24,7 +24,7 @@ export class ShowAvatarImage extends LitElement { /** * REQUIRED. The hash of the image to be rendered */ - @property(hashProperty("image-hash")) imageHash!: EntryHash; + @property(hashProperty("image-hash")) imageHash: EntryHash | undefined; @property() shape: "circle" | "square" | "rounded" = "circle"; @@ -44,19 +44,19 @@ export class ShowAvatarImage extends LitElement { _renderImage = new Task( this, async ([fileHash]) => { - const image = await getImage(fileHash); + const image = await getImage(fileHash!); if (image) { return image; } - const file = await this.client.downloadFile(fileHash); + const file = await this.client.downloadFile(fileHash!); const data = await file.arrayBuffer(); const imageB64 = `data:${file.type};base64,${fromUint8Array( new Uint8Array(data) )}`; - storeImage(fileHash, imageB64); + storeImage(fileHash!, imageB64); return imageB64; }, @@ -75,6 +75,16 @@ export class ShowAvatarImage extends LitElement { } render() { + if (!this.imageHash) { + return html` + + `; + } + return this._renderImage.render({ complete: (d) => this.renderImage(d), pending: () =>