aboutsummaryrefslogtreecommitdiff
path: root/src/components/user_avatar/user_avatar.js
blob: 33d9a2580be09a1895752119118a044e1ec55315 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import StillImage from '../still-image/still-image.vue'

import { library } from '@fortawesome/fontawesome-svg-core'

import {
  faRobot
} from '@fortawesome/free-solid-svg-icons'

library.add(
  faRobot
)

const UserAvatar = {
  props: [
    'user',
    'betterShadow',
    'compact',
    'bot'
  ],
  data () {
    return {
      showPlaceholder: false,
      defaultAvatar: `${this.$store.state.instance.server + this.$store.state.instance.defaultAvatar}`
    }
  },
  components: {
    StillImage
  },
  methods: {
    imgSrc (src) {
      return (!src || this.showPlaceholder) ? this.defaultAvatar : src
    },
    imageLoadError () {
      this.showPlaceholder = true
    }
  }
}

export default UserAvatar