diff --git a/app/mobile/src/api/getListing.js b/app/mobile/src/api/getListing.js index 4a77ff10..753c610f 100644 --- a/app/mobile/src/api/getListing.js +++ b/app/mobile/src/api/getListing.js @@ -1,12 +1,8 @@ import { checkResponse, fetchWithTimeout } from './fetchUtil'; -export async function getListing(server) { - let host = ""; - if (server) { - host = `https://${server}`; - } - - let listing = await fetchWithTimeout(`${host}/account/listing`, { method: 'GET' }); +export async function getListing(server, filter) { + const param = filter ? `?filter=${filter}` : ''; + let listing = await fetchWithTimeout(`https://${server}/account/listing${param}`, { method: 'GET' }); checkResponse(listing); return await listing.json(); } diff --git a/app/mobile/src/session/registry/Registry.jsx b/app/mobile/src/session/registry/Registry.jsx index 2fe6cba0..557b093b 100644 --- a/app/mobile/src/session/registry/Registry.jsx +++ b/app/mobile/src/session/registry/Registry.jsx @@ -24,10 +24,20 @@ export function RegistryTitle({ state, actions }) { return ( + { !state.filter && ( + + + + )} + { state.filter && ( + + + + )} - { state.busy && ( diff --git a/app/mobile/src/session/registry/Registry.styled.js b/app/mobile/src/session/registry/Registry.styled.js index 30b424bf..2493ea12 100644 --- a/app/mobile/src/session/registry/Registry.styled.js +++ b/app/mobile/src/session/registry/Registry.styled.js @@ -40,6 +40,17 @@ export const styles = StyleSheet.create({ paddingBottom: 8, alignItems: 'center', }, + filterwrapper: { + display: 'flex', + flexDirection: 'row', + borderRadius: 4, + backgroundColor: Colors.white, + alignItems: 'center', + paddingTop: 4, + paddingBottom: 4, + marginLeft: 8, + width: '25%', + }, inputwrapper: { display: 'flex', flexDirection: 'row', @@ -100,8 +111,6 @@ export const styles = StyleSheet.create({ alignItems: 'center', padding: 8, borderRadius: 4, - }, - newtext: { paddingLeft: 8, color: Colors.white, }, diff --git a/app/mobile/src/session/registry/useRegistry.hook.js b/app/mobile/src/session/registry/useRegistry.hook.js index 47baf455..26a53664 100644 --- a/app/mobile/src/session/registry/useRegistry.hook.js +++ b/app/mobile/src/session/registry/useRegistry.hook.js @@ -12,6 +12,8 @@ export function useRegistry() { tabbed: null, accounts: [], server: null, + filter: false, + username: null, busy: false, }); @@ -47,7 +49,13 @@ export function useRegistry() { if (!state.busy) { try { updateState({ busy: true }); - const accounts = await getListing(server, true); + let accounts; + if (state.filter && state.username) { + accounts = await getListing(server, state.username); + } + else { + accounts = await getListing(server); + } const filtered = accounts.filter(item => { if (item.guid === profile.state.profile.guid) { return false; @@ -74,7 +82,13 @@ export function useRegistry() { }, search: async () => { await getAccounts(state.server, false); - } + }, + filter: async () => { + updateState({ filter: true }); + }, + setUsername: async (username) => { + updateState({ username }); + }, }; return { state, actions };