Skip to content

Commit

Permalink
add new group-level assets logic and trickleICE toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
matthme committed Jan 8, 2025
1 parent eabdce2 commit 1a946fc
Show file tree
Hide file tree
Showing 10 changed files with 364 additions and 342 deletions.
359 changes: 184 additions & 175 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"devDependencies": {
"@holochain-playground/cli": "^0.1.1",
"@theweave/cli": "0.13.0-rc.0",
"@theweave/cli": "0.13.0-rc.1",
"concurrently": "^6.2.1",
"rimraf": "^3.0.2"
},
Expand Down
14 changes: 7 additions & 7 deletions ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ui",
"version": "0.10.0-alpha.1",
"version": "0.10.0-beta.0",
"scripts": {
"start": "vite --port $UI_PORT --clearScreen false",
"build": "vite build",
Expand All @@ -14,13 +14,13 @@
"@fontsource-variable/noto-sans-sc": "^5.0.5",
"@fontsource/ubuntu": "^5.0.12",
"@fontsource-variable/baloo-2": "5.0.19",
"@holochain/client": "0.18.0-rc.1",
"@holochain/client": "0.18.0",
"@holo-host/identicon": "^0.1.0",
"@holochain-open-dev/elements": "0.400.0-rc.0",
"@holochain-open-dev/profiles": "0.400.0-rc.0",
"@holochain-open-dev/stores": "0.400.0-rc.0",
"@holochain-open-dev/utils": "0.400.0-rc.0",
"@theweave/api": "0.4.0-alpha.0",
"@holochain-open-dev/elements": "0.400.0",
"@holochain-open-dev/profiles": "0.400.0",
"@holochain-open-dev/stores": "0.400.0",
"@holochain-open-dev/utils": "0.400.0",
"@theweave/api": "0.4.0-alpha.3",
"@lit/context": "^1.1.0",
"@lit/task": "^1.0.0",
"@lit/localize": "0.12.1",
Expand Down
44 changes: 12 additions & 32 deletions ui/src/attachment-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ import '@shoelace-style/shoelace/dist/components/tooltip/tooltip.js';
import {
AppletInfo,
AssetLocationAndInfo,
WAL,
WalRelationAndTags,
WeaveClient,
weaveUrlToLocation,
} from '@theweave/api';
import { EntryRecord } from '@holochain-open-dev/utils';
import { mdiTrashCan } from '@mdi/js';

import { wrapPathInSvg } from '@holochain-open-dev/elements';
import { sharedStyles } from './sharedStyles';
import './avatar-with-nickname';
import { Attachment, weaveClientContext } from './types';
import { weaveClientContext } from './types';

@localized()
@customElement('attachment-element')
Expand All @@ -28,7 +26,7 @@ export class AttachmentElement extends LitElement {
_weaveClient!: WeaveClient;

@property()
entryRecord!: EntryRecord<Attachment>;
walRelationAndTags!: WalRelationAndTags;

@state()
_error: string | undefined;
Expand All @@ -39,20 +37,8 @@ export class AttachmentElement extends LitElement {
@state()
_assetAppletInfo: AppletInfo | undefined;

@state()
_wal: WAL | undefined;

async updateAssetInfo() {
const weaveLocation = weaveUrlToLocation(this.entryRecord.entry.wal);
if (weaveLocation.type !== 'asset') {
this._error = 'Invalid URL';
return;
}
this._assetInfo = await this._weaveClient.assets.assetInfo(weaveLocation.wal);
this._wal = weaveLocation.wal;
this._assetAppletInfo = this._assetInfo
? await this._weaveClient.appletInfo(this._assetInfo.appletHash)
: undefined;
this._assetInfo = await this._weaveClient.assets.assetInfo(this.walRelationAndTags.wal);
}

async firstUpdated() {
Expand All @@ -62,23 +48,17 @@ export class AttachmentElement extends LitElement {
protected async willUpdate(
changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>
) {
if (changedProperties.has('entryRecord')) {
if (changedProperties.has('wal')) {
await this.updateAssetInfo();
}
}

async openAsset() {
if (this._wal) {
await this._weaveClient.openAsset(this._wal);
}
await this._weaveClient.openAsset(this.walRelationAndTags.wal);
}

removeAttachment() {
this.dispatchEvent(
new CustomEvent('remove-attachment', {
detail: this.entryRecord,
})
);
async removeAttachment() {
await this._weaveClient.assets.removeAssetRelation(this.walRelationAndTags.relationHash);
}

render() {
Expand Down Expand Up @@ -128,13 +108,13 @@ export class AttachmentElement extends LitElement {
<div
tabindex="0"
class="column center-content delete-btn tertiary-font"
@click=${(e: any) => {
this.removeAttachment();
@click=${async (e: any) => {
e.stopPropagation();
await this.removeAttachment();
}}
@keypress=${(e: KeyboardEvent) => {
@keypress=${async (e: KeyboardEvent) => {
if (e.key === 'Enter' || e.key === ' ') {
this.removeAttachment();
await this.removeAttachment();
}
}}
>
Expand Down
7 changes: 7 additions & 0 deletions ui/src/presence-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
GroupPermissionType,
GroupProfile,
NULL_HASH,
WAL,
WeaveClient,
initializeHotReload,
isWeaveContext,
Expand Down Expand Up @@ -106,6 +107,9 @@ export class PresenceApp extends LitElement {
@state()
_selectedRoleName: RoleName | undefined;

@state()
_selectedWal: WAL | undefined;

@state()
_displayError: string | undefined;

Expand Down Expand Up @@ -245,6 +249,8 @@ export class PresenceApp extends LitElement {
const dnaHash = wal.hrl[0];
const dnaHashB64 = encodeHashToBase64(dnaHash);

this._selectedWal = wal;

if (encodeHashToBase64(cellTypes.provisioned.cell_id[0]) === dnaHashB64) {
this._selectedRoleName = 'presence';
this._pageView = PageView.Room;
Expand Down Expand Up @@ -804,6 +810,7 @@ export class PresenceApp extends LitElement {
<room-container
class="room-container"
.roleName=${this._selectedRoleName}
.wal=${this._selectedWal}
@quit-room=${async () => {
if (this.externalWindow) {
console.log('Closing window.');
Expand Down
7 changes: 5 additions & 2 deletions ui/src/room-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { customElement, property, state } from 'lit/decorators.js';
import { AppClient, RoleName } from '@holochain/client';
import { localized } from '@lit/localize';
import { consume, provide } from '@lit/context';
import { WeaveClient } from '@theweave/api';
import { WAL, WeaveClient } from '@theweave/api';

import '@shoelace-style/shoelace/dist/components/icon/icon.js';
import '@shoelace-style/shoelace/dist/components/tooltip/tooltip.js';
Expand Down Expand Up @@ -44,6 +44,9 @@ export class RoomContainer extends LitElement {
@property()
roleName!: RoleName;

@property()
wal!: WAL;

@state()
_private = false;

Expand Down Expand Up @@ -77,7 +80,7 @@ export class RoomContainer extends LitElement {

render() {
if (this.loading) return html``;
return html` <room-view ?private=${this._private}></room-view> `;
return html` <room-view ?private=${this._private} .wal=${this.wal}></room-view> `;
}

static styles = [sharedStyles, css``];
Expand Down
Loading

0 comments on commit 1a946fc

Please sign in to comment.