diff --git a/web/src/components/PostCard.vue b/web/src/components/PostCard.vue
index 1fd95bd..93eca52 100644
--- a/web/src/components/PostCard.vue
+++ b/web/src/components/PostCard.vue
@@ -1,7 +1,13 @@
-
-
{{ post.content }}
+
+
+
+
+
@@ -15,26 +21,63 @@ export default {
},
data () {
return {
- post: {}
+ post: {},
+ actor: {},
+ isError: false,
}
},
- created () {
- if (typeof this.activity.object === 'string') {
- window.fetch(`/o/${encodeURIComponent(this.activity.object)}`, {
+ computed: {
+ actorIconUrl() {
+ return this.actor.icon && this.actor.icon.url
+ },
+ actorHost() {
+ try {
+ const id = new URL(this.actor.id)
+ return id.host
+ } catch (ignore) {
+ return ''
+ }
+ }
+ },
+ methods: {
+ resolveObject(idOrObject) {
+ if (typeof idOrObject !== 'string') {
+ return new Promise((resolve) => resolve(idOrObject))
+ }
+ return window.fetch(`/o/${encodeURIComponent(idOrObject)}`, {
method: 'get',
headers: {
accept: 'application/activity+json'
}
- }).then(res => res.json())
- .then(post => {
- this.post = post
- })
+ })
+ .then(res => res.json())
.catch(err => {
- this.post.content = err.message
+ this.isError = true
+ console.log(err.message)
})
- } else {
- this.post = this.activity.object
}
+ },
+ created () {
+ this.resolveObject(this.activity.object)
+ .then(object => {
+ this.post = object
+ return this.resolveObject(this.post.attributedTo)
+ })
+ .then(actor => { this.actor = actor })
}
}
-
\ No newline at end of file
+
+
+
\ No newline at end of file