summaryrefslogtreecommitdiff
path: root/components/private-messaging.js
diff options
context:
space:
mode:
authorAnthony Wang2023-02-15 16:22:43 -0500
committerAnthony Wang2023-02-15 16:22:43 -0500
commit091ff04c2420c8549ff581399212b4e3346864ee (patch)
tree746ad8767db3f3eab288eab4f08b74c37742777e /components/private-messaging.js
parentfb3c976380e704a1c129f141f0bdb7f5f4576611 (diff)
Delete all files except for demo
Diffstat (limited to 'components/private-messaging.js')
-rw-r--r--components/private-messaging.js66
1 files changed, 66 insertions, 0 deletions
diff --git a/components/private-messaging.js b/components/private-messaging.js
new file mode 100644
index 0000000..61f783b
--- /dev/null
+++ b/components/private-messaging.js
@@ -0,0 +1,66 @@
+import Chat from './chat.js'
+import {Name} from './name.js'
+
+export default {
+
+ data: ()=> ({
+ recipient: null,
+ message: ''
+ }),
+
+ methods: {
+ messageObjects: Chat.methods.messageObjects,
+ chatObjects(objects) {
+ return this.messageObjects(objects).filter(o=>
+ '_to' in o && o._to.length == 1)
+ },
+
+ sendMessage() {
+ if (!this.message) return
+ this.$graffitiUpdate({
+ message: this.message,
+ timestamp: Date.now(),
+ _to: [this.recipient],
+ _tags: [this.$graffitiMyID, this.recipient]
+ })
+ this.message = ''
+ }
+ },
+
+ template: `
+ Send private message to:
+ <graffiti-objects :tags="['demo']" v-slot="{objects}">
+ <select v-model="recipient">
+ <option v-for="id in objects.notMine.authors" :value="id">
+ <Name :of="id">
+ </option>
+ </select>
+ </graffiti-objects>
+
+ <form @submit.prevent="sendMessage">
+ <input v-model="message">
+ <input type="submit" value="Submit"/>
+ </form>
+
+ <graffiti-objects :tags="[$graffitiMyID]" v-slot="{objects}">
+
+ <h3>My Outbox</h3>
+
+ <ul v-for="object in chatObjects(objects).mine">
+ <li>
+ To <em><Name :of="object._to[0]"/></em>:
+ {{ object.message }}
+ </li>
+ </ul>
+
+ <h3>My Inbox</h3>
+
+ <ul v-for="object in chatObjects(objects).notMine">
+ <li>
+ From <em><Name :of="object._by"/></em>:
+ {{ object.message }}
+ </li>
+ </ul>
+
+ </graffiti-objects>`
+}