2017-11-15 08:12:56 +00:00
|
|
|
<template>
|
|
|
|
<span class="user-name">{{name}}</span>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import userSvc from '../services/userSvc';
|
2018-09-19 08:59:22 +00:00
|
|
|
import store from '../store';
|
2017-11-15 08:12:56 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
props: ['userId'],
|
|
|
|
computed: {
|
2019-06-22 21:19:01 +00:00
|
|
|
sanitizedUserId() {
|
|
|
|
return userSvc.sanitizeUserId(this.userId);
|
|
|
|
},
|
2017-11-15 08:12:56 +00:00
|
|
|
name() {
|
2019-06-22 21:19:01 +00:00
|
|
|
const userInfo = store.state.userInfo.itemsById[this.sanitizedUserId];
|
2017-11-15 08:12:56 +00:00
|
|
|
return userInfo ? userInfo.name : 'Someone';
|
|
|
|
},
|
|
|
|
},
|
2018-09-19 08:59:22 +00:00
|
|
|
watch: {
|
2019-06-22 21:19:01 +00:00
|
|
|
sanitizedUserId: {
|
|
|
|
handler: sanitizedUserId => userSvc.addUserId(sanitizedUserId),
|
2018-09-19 08:59:22 +00:00
|
|
|
immediate: true,
|
|
|
|
},
|
|
|
|
},
|
2017-11-15 08:12:56 +00:00
|
|
|
};
|
|
|
|
</script>
|