logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

lists_user_search.js (1100B)


  1. import { library } from '@fortawesome/fontawesome-svg-core'
  2. import {
  3. faSearch,
  4. faChevronLeft
  5. } from '@fortawesome/free-solid-svg-icons'
  6. import { debounce } from 'lodash'
  7. import Checkbox from '../checkbox/checkbox.vue'
  8. library.add(
  9. faSearch,
  10. faChevronLeft
  11. )
  12. const ListsUserSearch = {
  13. components: {
  14. Checkbox
  15. },
  16. emits: ['loading', 'loadingDone', 'results'],
  17. data () {
  18. return {
  19. loading: false,
  20. query: '',
  21. followingOnly: true
  22. }
  23. },
  24. methods: {
  25. onInput: debounce(function () {
  26. this.search(this.query)
  27. }, 2000),
  28. search (query) {
  29. if (!query) {
  30. this.loading = false
  31. return
  32. }
  33. this.loading = true
  34. this.$emit('loading')
  35. this.userIds = []
  36. this.$store.dispatch('search', { q: query, resolve: true, type: 'accounts', following: this.followingOnly })
  37. .then(data => {
  38. this.$emit('results', data.accounts.map(a => a.id))
  39. })
  40. .finally(() => {
  41. this.loading = false
  42. this.$emit('loadingDone')
  43. })
  44. }
  45. }
  46. }
  47. export default ListsUserSearch