Skip to content
Snippets Groups Projects

Always show fresh relationship status in search, better error handling.

Closed lain requested to merge user-search-better-error-handling into develop
2 unresolved threads

This will no properly handle timeouts as well (it would just spin forever before)

Mass fetching ids did not work, i guess because the query array syntax is wrong.

Edited by lain

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
27 34 this.$router.push({ name: 'user-search', query: { query } })
28 35 this.$refs.userSearchInput.focus()
29 36 },
30 search (query) {
37 async search (query) {
31 38 if (!query) {
32 this.users = []
33 39 return
34 40 }
41
35 42 this.loading = true
36 userSearchApi.search({query, store: this.$store})
37 .then((res) => {
38 this.loading = false
39 this.users = res
43 try {
  • I do not like the try/catch pattern, switching a promise to an async/await is good if it stays simple but here it's a tradeoff for the worse as we need a try/catch/finally too

  • Please register or sign in to reply
  • lain mentioned in merge request !754 (merged)

    mentioned in merge request !754 (merged)

  • Tae Hoon
    Tae Hoon @tae started a thread on the diff
  • 32 this.users = []
    33 39 return
    34 40 }
    41
    35 42 this.loading = true
    36 userSearchApi.search({query, store: this.$store})
    37 .then((res) => {
    38 this.loading = false
    39 this.users = res
    43 try {
    44 this.userIds = []
    45 const users = await userSearchApi.search({ query, store: this.$store })
    46 this.$store.commit('addNewUsers', users)
    47 each(users, ({ id }) => {
    48 this.userIds.push(id)
    49 this.$store.dispatch('fetchUserRelationship', id)
  • Solved in !754 (merged) so closing here.

  • closed

  • @lambadalambda thank you for choosing my solution. :taco:

  • Please register or sign in to reply
    Loading