label.id && handleToggleLabel(label.id)}
- className="font-normal"
- >
-
- label.id).includes(label.id) : false
- }
- className="mr-2 h-4 w-4"
- />
- {label.name}
-
-
- ))}
+ .map((label) => {
+ let isChecked = label.id ? thread.labels?.map((l) => l.id).includes(label.id) : false;
+
+ const checkboxOptimisticState = useOptimisticThreadState(threadId);
+ if (label.id && checkboxOptimisticState.optimisticLabels) {
+ if (checkboxOptimisticState.optimisticLabels.addedLabelIds.includes(label.id)) {
+ isChecked = true;
+ } else if (
+ checkboxOptimisticState.optimisticLabels.removedLabelIds.includes(label.id)
+ ) {
+ isChecked = false;
+ }
+ }
+
+ return (
+