Skip to content

Commit

Permalink
Handle multiple profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Oct 30, 2024
1 parent cfebe32 commit c2f59c9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
nixpkgs.follows = "holonix/nixpkgs";
holonix.url = "github:holochain/holonix/main-0.3";
hc-infra.url = "github:holochain-open-dev/infrastructure";
p2p-shipyard.url = "github:darksoil-studio/p2p-shipyard/develop";
p2p-shipyard.url = "github:darksoil-studio/p2p-shipyard";
playground.url = "github:darksoil-studio/holochain-playground";
linked-devices.url = "github:darksoil-studio/linked-devices";
};
Expand Down
6 changes: 4 additions & 2 deletions ui/src/elements/profile-prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ export class ProfilePrompt extends SignalWatcher(LitElement) {
await this.store.client.getAgentProfile(linkedDevice);
if (profileForLinkedDeviceLinks.length > 0) {
const profileForLinkedDevice =
profileForLinkedDeviceLinks[0].target;
const latestLink = profileForLinkedDeviceLinks.sort(
(l1, l2) => l2.timestamp - l1.timestamp,
)[0];
const profileForLinkedDevice = latestLink.target;
await this.store.client.linkMyAgentToProfile(
profileForLinkedDevice,
);
Expand Down
5 changes: 4 additions & 1 deletion ui/src/profiles-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ export class ProfilesStore {

// TODO: handle multiple links gracefully

const profileHash = links.value[0].target;
const latestLink = links.value.sort(
(l1, l2) => l2.timestamp - l1.timestamp,
)[0];
const profileHash = latestLink.target;
return {
status: 'completed',
value: this.profiles.get(profileHash),
Expand Down

0 comments on commit c2f59c9

Please sign in to comment.