blob: 08b478b9a560303531f05c2fa519626e967d7660 (
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
import { Name } from './name.js'
import LikeButton from './like-button.js'
export default {
components: { Name, LikeButton },
data: ()=> ({
message: '',
channel: 'demo'
}),
methods: {
messageObjects(objects) {
return objects.filter(o=>
'message' in o &&
'timestamp' in o &&
typeof o.message == 'string' &&
typeof o.timestamp == 'number')
.sortBy('timestamp')
},
sendMessage() {
if (!this.message) return
this.$graffitiUpdate({
message: this.message,
timestamp: Date.now(),
_tags: [this.channel]
})
this.message = ''
}
},
template: `
Chat Channel: <input v-model="channel"/>
<graffiti-objects :tags="[channel]" v-slot="{objects}">
<ul v-for="object in messageObjects(objects)">
<li>
<em><Name :of="object._by"/></em>:
{{ object.message }}
<LikeButton :messageID="object._id" />
<template v-if="object._by==$graffitiMyID">
<button @click="object.message+='!!';object._update()">
‼️
</button>
<button @click="object._remove()">
❌
</button>
</template>
</li>
</ul>
</graffiti-objects>
<form @submit.prevent="sendMessage">
<input v-model="message">
<input type="submit" value="Submit"/>
</form>`
}
|