mirror of
https://github.com/liyunze-coding/rython-task-bot-v2.git
synced 2026-09-22 07:24:27 +00:00
0.2.2 Optimized Focus Task
This commit is contained in:
parent
b065cd2138
commit
b2d7c74cf9
2 changed files with 12 additions and 9 deletions
11
Code.cs
11
Code.cs
|
|
@ -377,6 +377,8 @@ public class TaskOperations
|
|||
|
||||
if (taskData[key].Tasks.Any(t => t.Name.Equals(taskName, StringComparison.OrdinalIgnoreCase) && !t.Completed))
|
||||
return new Response<(int, string)>(false, default, $"❌ Error: Task '{taskName}' already exists");
|
||||
if (focused)
|
||||
Unfocus();
|
||||
taskData[key].Username = getUsername();
|
||||
taskData[key].Tasks.Add(new Task(taskName, completed, focused));
|
||||
if (completed)
|
||||
|
|
@ -453,18 +455,18 @@ public class TaskOperations
|
|||
public void Unfocus()
|
||||
{
|
||||
var tasks = ListUserTasks();
|
||||
UnfocusAll(tasks);
|
||||
tasks = UnfocusAll(tasks);
|
||||
SaveIntoTasks(tasks);
|
||||
}
|
||||
|
||||
private void UnfocusAll(List<Task> tasks)
|
||||
private List<Task> UnfocusAll(List<Task> tasks)
|
||||
{
|
||||
for (int i = 0; i < tasks.Count; i++)
|
||||
tasks[i].Focused = false;
|
||||
|
||||
return tasks;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void SaveIntoTasks(List<Task> tasks)
|
||||
{
|
||||
string key = getKey();
|
||||
|
|
@ -1114,6 +1116,7 @@ public class CPHInline
|
|||
{
|
||||
Respond($"You have completed {completedCount} task(s) so far!");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue