Skip to content

Commit

Permalink
fix AnyAgent bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zippy committed Aug 7, 2024
1 parent 71b016c commit 160da35
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
9 changes: 5 additions & 4 deletions ui/src/emergence-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function fixAnyAgent(a:AnyAgent) {
return {type:x, hash:a.hash}
}
export function unfixAnyAgent(a:any): AnyAgent {
console.log("FISHIN ANY AGENT", a)
const type = Object.keys(a.type)[0]
//@ts-ignore
const x:AnyAgent = {type, hash:a.hash}
Expand Down Expand Up @@ -114,15 +115,15 @@ export class EmergenceClient {
trashed: false
};

// @ts-ignore
sessionEntry.leaders = sessionEntry.leaders.map(l=>fixAnyAgent(l))
// // @ts-ignore
// sessionEntry.leaders = sessionEntry.leaders.map(l=>fixAnyAgent(l))
console.log("NEW SES", sessionEntry)
return new EntryRecord(await this.callZome('create_session', sessionEntry))
}

async updateSession(update: UpdateSessionInput) : Promise<EntryRecord<Session>> {
// @ts-ignore
update.updated_leaders = update.updated_leaders.map(l=>fixAnyAgent(l))
// // @ts-ignore
// update.updated_leaders = update.updated_leaders.map(l=>fixAnyAgent(l))
return new EntryRecord(await this.callZome('update_session', update))
}

Expand Down
6 changes: 4 additions & 2 deletions ui/src/emergence/emergence/AnyAvatar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</script>
{#if agent.type=="Agent"}
<Avatar size={size} namePosition={namePosition} showAvatar={showAvatar} showNickname={showNickname} agentPubKey={agent.hash}></Avatar>
{:else}
{:else if agent.type=="ProxyAgent"}
<div class="avatar-{namePosition} clickable"
on:click={(e)=>{
store.openDetails(DetailsType.ProxyAgent, agent.hash)
Expand All @@ -30,13 +30,15 @@
{#if proxyAgent}
<span style="margin-right:5px"><ProxyAgentAvatar size={size} proxyAgentHash={proxyAgent.original_hash}></ProxyAgentAvatar></span>
{:else}
No Agent!
<span style="color:red" title="Proxy Agent Missing">(?)</span>
{/if}
{/if}
{#if showNickname}
<div class="nickname">{proxyAgent ? proxyAgent.record.entry.nickname : "unknown"}</div>
{/if}
</div>
{:else}
<span style="color:red" title="Unknown agent type">(?)</span>
{/if}

<style>
Expand Down
4 changes: 2 additions & 2 deletions ui/src/emergence/emergence/ProxyAgentDetail.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
$: sessions = $allSessions.filter((s) =>
s.record.entry.leaders.find(
(l) =>
encodeHashToBase64(l.hash) ==
encodeHashToBase64($proxyAgent.original_hash)
$proxyAgent.original_hash && (encodeHashToBase64(l.hash) ==
encodeHashToBase64($proxyAgent.original_hash))
)
);
Expand Down
3 changes: 2 additions & 1 deletion ui/src/emergence/emergence/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ export interface SessionEntryRecord {

export const makeSRec = (record: EntryRecord<Session>): SessionEntryRecord => {
let entry = record.entry
entry.leaders = entry.leaders.map(l=>unfixAnyAgent(l))
// console.log("LEADERS", entry.leaders)
// entry.leaders = entry.leaders.map(l=>unfixAnyAgent(l))

let sRec: SessionEntryRecord = {
entry,
Expand Down

0 comments on commit 160da35

Please sign in to comment.