diff --git a/src/components/Thread.vue b/src/components/Thread.vue
index b659d23..5736f1a 100644
--- a/src/components/Thread.vue
+++ b/src/components/Thread.vue
@@ -17,14 +17,14 @@
openmenu(e, i)">
- {{ sourceObj.contacts[event.contact].name }} created a new thread called "{{ item.threads[event.thread].title }} "
+ {{ sourceObj.contacts[event.contact].name }} created a new thread called "{{ item.threads[event.thread].title }} "
-
+
Edit
Delete
- Create thread
- Create to do
- Add to garden
+ Create thread
+ Create to do
+ Add to garden
@@ -37,7 +37,9 @@
import { computed, onUnmounted, ref, watch } from 'vue';
import { items, sources } from '../state';
import Avatar from './Avatar.vue';
-import { RouterLink } from 'vue-router';
+import { RouterLink, useRouter } from 'vue-router';
+
+const router = useRouter();
const props = defineProps<{
source: number;
@@ -160,6 +162,27 @@ function deleteMessage(event: number) {
threadItem.value.timeline.splice(event, 1);
selectedMessageIndex.value = undefined;
}
+
+function createThread(event: number) {
+ const messageEvent = threadItem.value.timeline[event];
+ if (messageEvent.type !== "message") {
+ return;
+ }
+
+ const threadId = Object.keys(item.value.threads).reduce((acc, curr) => Math.max(acc, parseInt(curr)), 0) + 1;
+ item.value.threads[threadId] = {
+ id: threadId,
+ timeline: [messageEvent],
+ title: messageEvent.message
+ };
+ threadItem.value.timeline.push({
+ contact: sourceObj.value.selfContact,
+ type: "create-thread",
+ time: Date.now(),
+ thread: threadId
+ });
+ router.push(`/source/${props.source}/${props.sourceItem}/${threadId}`);
+}