Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Automatically add the user to the subscriber list if user adds a comment

天舟5e43a0fbaa64
diff --git a/frontend/src/views/TaskActivityPanel.vue b/frontend/src/views/TaskActivityPanel.vue
index e1f9f2a960..64a8ea2401 100644
--- a/frontend/src/views/TaskActivityPanel.vue
+++ b/frontend/src/views/TaskActivityPanel.vue
@@ -300,6 +300,7 @@ import {
Activity,
ActionTaskFieldUpdatePayload,
Environment,
+ Principal,
} from "../types";
import { sizeToFit, stageName } from "../utils";
import { fieldFromId, TaskTemplate, TaskBuiltinFieldId } from "../plugins";
@@ -312,6 +313,7 @@ interface LocalState {
export default {
name: "TaskActivityPanel",
+ emits: ["update-subscriber-list"],
props: {
task: {
required: true,
@@ -323,7 +325,7 @@ export default {
},
},
components: {},
- setup(props, ctx) {
+ setup(props, { emit }) {
const store = useStore();
const newComment = ref("");
const newCommentTextArea = ref();
@@ -416,6 +418,23 @@ export default {
.then(() => {
newComment.value = "";
nextTick(() => sizeToFit(newCommentTextArea.value));
+
+ // Because the user just added a comment and we assume she is interested in this
+ // task, and we add her to the subscriber list if she is not there
+ let isSubscribed = false;
+ for (const principal of props.task.subscriberList) {
+ if (principal.id == currentUser.value.id) {
+ isSubscribed = true;
+ break;
+ }
+ }
+ if (!isSubscribed) {
+ const list = props.task.subscriberList.map((item: Principal) => {
+ return item.id;
+ });
+ list.push(currentUser.value.id);
+ emit("update-subscriber-list", list);
+ }
})
.catch((error) => {
console.log(error);
diff --git a/frontend/src/views/TaskDetail.vue b/frontend/src/views/TaskDetail.vue
index 645fde074e..08c3725a51 100644
--- a/frontend/src/views/TaskDetail.vue
+++ b/frontend/src/views/TaskDetail.vue
@@ -133,6 +133,7 @@
<TaskActivityPanel
:task="state.task"
:taskTemplate="taskTemplate"
+ @update-subscriber-list="updateSubscriberIdList"
/>
</section>
</div>