Skip to content

Commit

Permalink
Fixed discover agent bug
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Dec 6, 2024
1 parent 19a5184 commit 1a5db70
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
12 changes: 3 additions & 9 deletions ui/src/elements/discover-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
decodeHashFromBase64,
encodeHashToBase64,
} from '@holochain/client';
import { ResizeController } from '@lit-labs/observers/resize-controller.js';
import { consume } from '@lit/context';
import { localized, msg } from '@lit/localize';
import { decode } from '@msgpack/msgpack';
Expand Down Expand Up @@ -33,13 +32,6 @@ export async function scanQrcode(): Promise<string> {
return result.content;
}

export async function scanMsgpackQrCode<T>(): Promise<T> {
const content = await scanQrcode();
const payload = decode(toUint8Array(content)) as T;

return payload;
}

@localized()
@customElement('discover-agent')
export class DiscoverAgent extends SignalWatcher(LitElement) {
Expand All @@ -66,10 +58,11 @@ export class DiscoverAgent extends SignalWatcher(LitElement) {
}

async scanAndDiscover() {
const agentPubKey: AgentPubKey = await scanMsgpackQrCode();
const agentPubKey: AgentPubKey = decodeHashFromBase64(await scanQrcode());
try {
await this.attemptDiscoverAgent(agentPubKey);
} catch (e) {
console.error(e);
await this.scanAndDiscover();
}
}
Expand All @@ -95,6 +88,7 @@ export class DiscoverAgent extends SignalWatcher(LitElement) {
try {
await this.scanAndDiscover();
} catch (e) {
notifyError(msg('Error discovering agent. Please try again.'));
this.dispatchEvent(
new CustomEvent('link-devices-cancelled', {
bubbles: true,
Expand Down
1 change: 0 additions & 1 deletion ui/src/elements/link-device-requestor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export class LinkDevicesRequestor extends SignalWatcher(LitElement) {
this.store.config.linkDevicePasscodeLength,
);
this.interval = setInterval(async () => {
console.log('now');
this.requestorPasscode = randomPasscode(
this.store.config.linkDevicePasscodeLength,
);
Expand Down

0 comments on commit 1a5db70

Please sign in to comment.