From c34eebff6c1bb0d3f500b51ee64906f82cdc6c6d Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 14 Nov 2018 20:29:45 +0100 Subject: [PATCH] Add actual user search. --- src/boot/after_store.js | 4 ++- src/components/user_finder/user_finder.js | 17 +--------- src/components/user_finder/user_finder.vue | 4 --- src/components/user_search/user_search.js | 33 ++++++++++++++++++++ src/components/user_search/user_search.vue | 12 ++++++++ src/i18n/en.json | 3 +- src/services/new_api/user_search.js | 16 ++++++++++ src/services/new_api/utils.js | 36 ++++++++++++++++++++++ 8 files changed, 103 insertions(+), 22 deletions(-) create mode 100644 src/components/user_search/user_search.js create mode 100644 src/components/user_search/user_search.vue create mode 100644 src/services/new_api/user_search.js create mode 100644 src/services/new_api/utils.js diff --git a/src/boot/after_store.js b/src/boot/after_store.js index 90f25302..90c558f6 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -15,6 +15,7 @@ import Registration from '../components/registration/registration.vue' import UserSettings from '../components/user_settings/user_settings.vue' import FollowRequests from '../components/follow_requests/follow_requests.vue' import OAuthCallback from '../components/oauth_callback/oauth_callback.vue' +import UserSearch from '../components/user_search/user_search.vue' const afterStoreSetup = ({store, i18n}) => { window.fetch('/api/statusnet/config.json') @@ -95,7 +96,8 @@ const afterStoreSetup = ({store, i18n}) => { { name: 'registration', path: '/registration/:token', component: Registration }, { name: 'friend-requests', path: '/friend-requests', component: FollowRequests }, { name: 'user-settings', path: '/user-settings', component: UserSettings }, - { name: 'oauth-callback', path: '/oauth-callback', component: OAuthCallback, props: (route) => ({ code: route.query.code }) } + { name: 'oauth-callback', path: '/oauth-callback', component: OAuthCallback, props: (route) => ({ code: route.query.code }) }, + { name: 'user-search', path: '/user-search', component: UserSearch, props: (route) => ({ query: route.query.query }) } ] const router = new VueRouter({ diff --git a/src/components/user_finder/user_finder.js b/src/components/user_finder/user_finder.js index a743b5f6..74f79d1b 100644 --- a/src/components/user_finder/user_finder.js +++ b/src/components/user_finder/user_finder.js @@ -7,25 +7,10 @@ const UserFinder = { }), methods: { findUser (username) { - username = username[0] === '@' ? username.slice(1) : username - this.loading = true - this.$store.state.api.backendInteractor.externalProfile(username) - .then((user) => { - this.loading = false - this.hidden = true - if (!user.error) { - this.$store.commit('addNewUsers', [user]) - this.$router.push({name: 'user-profile', params: {id: user.id}}) - } else { - this.error = true - } - }) + this.$router.push({ name: 'user-search', query: { query: username } }) }, toggleHidden () { this.hidden = !this.hidden - }, - dismissError () { - this.error = false } } } diff --git a/src/components/user_finder/user_finder.vue b/src/components/user_finder/user_finder.vue index 69bd1d21..f2556569 100644 --- a/src/components/user_finder/user_finder.vue +++ b/src/components/user_finder/user_finder.vue @@ -1,9 +1,5 @@