From 8df90b1fc2f4cffc82f91df1a5bcb36ab78f23cc Mon Sep 17 00:00:00 2001 From: Ricardo Arturo Cabral Mejia Date: Sun, 30 Jan 2022 02:11:46 +0000 Subject: [PATCH] feat: add namedProfiles getter --- src/store/getters.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/store/getters.js b/src/store/getters.js index 2a755c2..8eeabaf 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -1,5 +1,14 @@ import Identicon from 'identicon.js' +export function namedProfiles(state, getters) { + return Object.entries(state.profilesCache) + .reduce((result, [pubkey, profile]) => getters.hasName(pubkey) + ? [...result, { ...profile, pubkey }] // [..., { name, pubkey, nip05, ...}, ...] + : result, + [] + ) +} + export function hasName(state) { return pubkey => { let {name, nip05} = state.profilesCache[pubkey] || {}