git ssb

3+

dangerousbeans / scuttle-vue



Tree: bdb6f71a74ac41de0e712971826b6f349b5ecaaa

Files: bdb6f71a74ac41de0e712971826b6f349b5ecaaa / src / components / Message.vue

1779 bytesRaw
1
2<template>
3 <div class="media mt-3 col-sm-8">
4 <img class="pr-3 rounded " style="max-width: 60px; " :src="image_url">
5 <div class="media-body col-sm-9">
6 <h5 class="mt-0 text-truncate">{{ author }}</h5>
7
8 <span v-if="" class="text-truncate" v-html="content_text()"></span>
9
10 <p>
11 {{ message.value.content.type() }}
12 </p>
13 </div>
14
15 {{ relatedMessages.length }} replies:
16 <message v-for="message in relatedMessages" :message="message">
17 </message>
18
19 <hr/>
20 </div>
21</template>
22
23<script>
24
25// var pull = require('pull-stream')
26import Rx from 'rxjs/RX'
27import { Observable } from 'rxjs/Observable'
28const nn = require('nevernull')
29const md = require('ssb-markdown')
30
31export default {
32 name: 'message',
33 props: ['message'],
34 data () {
35 return {
36 author: "...",
37 image_url: "http://via.placeholder.com/90x90",
38 relatedMessages: []
39 }
40 },
41
42 methods: {
43 setAuthor(err, a){
44 if(a[0] == null)
45 return
46 this.author = nn( a[0] ).name()
47 },
48
49 setRelatedMessages(err, a){
50
51 if(err) {
52 console.log('message.vue.setRelatedMessages.err', err)
53 }
54 // console.log(a)
55
56 // debugger
57 if(a)
58 this.relatedMessages = a.every(function(e){ nn(e) })
59 },
60
61 // Get markdown formatted version of message content
62 content_text()
63 {
64 return md.block( this.message.value.content.text() )
65 }
66 },
67 updated() {
68 // author name
69 this.$depject_api.signifier[0](
70 this.message.value.author(), this.setAuthor
71 )
72
73 this.$depject_api.getThread[0](
74 this.message.key(), this.setRelatedMessages
75 )
76
77 this.image_url = this.$depject_api.avatar_image[0](
78 this.message.value.author()
79 )
80 }
81}
82
83</script>
84
85<style scoped>
86</style>
87

Built with git-ssb-web