Reimplementation of the todo take turns feature to fix issues with only one assignee showing

This commit is contained in:
Dejan
2025-02-15 18:39:54 +01:00
parent f649828d80
commit 59664488e8
5 changed files with 22 additions and 7 deletions

View File

@ -174,7 +174,8 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
updateToDo({
...todo,
points: points,
assignees: selectedAssignees
assignees: selectedAssignees,
currentAssignee: selectedAssignees[0],
});
} else {
return;
@ -186,6 +187,7 @@ const AddChoreDialog = (addChoreDialogProps: IAddChoreDialog) => {
done: false,
points: points,
assignees: selectedAssignees,
currentAssignee: selectedAssignees[0],
repeatDays: todo.repeatDays ?? []
});
} else {

View File

@ -231,6 +231,13 @@ const ToDoItem = (props: {
</View>
<View row style={{ gap: 3 }}>
{selectedMembers?.map((member) => {
let currentAssignee = props?.item?.currentAssignee;
let opacity = 1;
if (selectedMembers?.length > 1 && currentAssignee !== member?.uid) {
opacity = 0.4;
}
return member?.pfp ? (
<ImageBackground
key={member?.uid}
@ -242,6 +249,7 @@ const ToDoItem = (props: {
overflow: "hidden",
borderWidth: 2,
borderColor: member.eventColor || "transparent",
opacity: opacity
}}
/>
) : (
@ -254,6 +262,7 @@ const ToDoItem = (props: {
borderWidth: 2,
borderRadius: 100,
borderColor: member.eventColor || "#ccc",
opacity: opacity
}}
>
<View

View File

@ -11,6 +11,7 @@ export interface IToDo {
creatorId?: string;
familyId?: string;
assignees?: string[]; // Optional list of assignees
currentAssignee?: string,
connectedTodoId?: string;
}

View File

@ -130,7 +130,7 @@ export const useCreateTodo = () => {
let assignee;
if (todoData.assignees && todoData.rotate && todoData?.assignees?.length !== 0) {
assignee = todoData.assignees[index % todoData.assignees.length];
assignee = todoData.assignees[(index + 1) % todoData.assignees.length];
}
const nextTodo = {
@ -140,7 +140,8 @@ export const useCreateTodo = () => {
familyId: profileData?.familyId,
creatorId: currentUser?.uid,
connectedTodoId: ruleDocRef.id,
assignees: assignee ? [assignee] : todoData.assignees
assignees: todoData.assignees,
currentAssignee: assignee
}
batch.set(newDocRef, nextTodo)

View File

@ -59,14 +59,15 @@ export const useUpdateTodo = () => {
const newDate = nextDates[index];
let assignee;
if (todoData.assignees && todoData.rotate && todoData?.assignees?.length !== 0) {
assignee = todoData.assignees[index % todoData.assignees.length];
assignee = todoData.assignees[(index + 1) % todoData.assignees.length];
}
if (newDate) {
const nextTodo = {
...todoData,
date: newDate,
assignees: assignee ? [assignee] : todoData.assignees
assignees: todoData.assignees,
currentAssignee: assignee
}
let docRef = todo.ref;
batch.update(docRef, nextTodo)
@ -83,7 +84,7 @@ export const useUpdateTodo = () => {
let assignee;
if (todoData.assignees && todoData.rotate && todoData?.assignees?.length !== 0) {
assignee = todoData.assignees[index % todoData.assignees.length];
assignee = todoData.assignees[(index + 1) % todoData.assignees.length];
}
const nextTodo = {
@ -93,7 +94,8 @@ export const useUpdateTodo = () => {
familyId: profileData?.familyId,
creatorId: currentUser?.uid,
connectedTodoId: todoData.connectedTodoId,
assignees: assignee ? [assignee] : todoData.assignees
assignees: todoData.assignees,
currentAssignee: assignee
}
batch.set(newDocRef, nextTodo)