Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
todo_data: Add method to check if task list is created by current user.
Pratik Chandafd9e458ab3b3
diff --git a/web/src/todo_data.ts b/web/src/todo_data.tsindex c5de23786ec..1615716dfaa 100644--- a/web/src/todo_data.ts+++ b/web/src/todo_data.ts@@ -2,6 +2,7 @@ import * as z from "zod/mini";import * as blueslip from "./blueslip.ts";import {$t} from "./i18n.ts";+import * as people from "./people.ts";// Any single user should send add a finite number of tasks// to a todo list. We arbitrarily pick this value.@@ -66,7 +67,6 @@ export type TodoWidgetOutboundData =export class TaskData {message_sender_id: number;me: number;- is_my_task_list: boolean;input_mode: boolean;report_error_function: (msg: string, more_info?: Record<string, unknown>) => void;task_list_title: string;@@ -80,7 +80,7 @@ export class TaskData {type: "new_task_list_title" as const,title,};- if (this.is_my_task_list) {+ if (this.is_my_task_list()) {return event;}return undefined;@@ -208,24 +208,19 @@ export class TaskData {constructor({message_sender_id,- current_user_id,- is_my_task_list,task_list_title,tasks,report_error_function,}: {message_sender_id: number;- current_user_id: number;- is_my_task_list: boolean;task_list_title: string;tasks: TodoTask[];report_error_function: (msg: string, more_info?: Record<string, unknown>) => void;}) {this.message_sender_id = message_sender_id;- this.me = current_user_id;- this.is_my_task_list = is_my_task_list;+ this.me = people.my_current_user_id();// input_mode indicates if the task list title is being input currently- this.input_mode = is_my_task_list; // for now+ this.input_mode = this.is_my_task_list(); // for nowthis.report_error_function = report_error_function;this.task_list_title = "";if (task_list_title) {@@ -244,6 +239,10 @@ export class TaskData {}}+ is_my_task_list(): boolean {+ return people.is_my_user_id(this.message_sender_id);+ }+set_task_list_title(new_title: string): void {this.input_mode = false;this.task_list_title = new_title;diff --git a/web/src/todo_widget.ts b/web/src/todo_widget.tsindex b785e633896..1473317f63a 100644--- a/web/src/todo_widget.ts+++ b/web/src/todo_widget.ts@@ -11,7 +11,6 @@ import {$t} from "./i18n.ts";import * as message_lists from "./message_lists.ts";import type {Message} from "./message_store.ts";import {page_params} from "./page_params.ts";-import * as people from "./people.ts";import type {TodoWidgetOutboundData} from "./todo_data.ts";import {TaskData} from "./todo_data.ts";import type {Event} from "./widget_data.ts";@@ -30,15 +29,13 @@ export function activate({}): (events: Event[]) => void {assert(any_data.widget_type === "todo");const {task_list_title = "", tasks = []} = any_data.extra_data ?? {};- const is_my_task_list = people.is_my_user_id(message.sender_id);const task_data = new TaskData({message_sender_id: message.sender_id,- current_user_id: people.my_current_user_id(),- is_my_task_list,task_list_title,tasks,report_error_function: blueslip.warn,});+ const is_my_task_list = task_data.is_my_task_list();const message_container = message_lists.current?.view.message_containers.get(message.id);function update_edit_controls(): void {