Skip to content

Commit

Permalink
Fix race condition when editing the "Check" field in the note (#967)
Browse files Browse the repository at this point in the history
Co-authored-by: Acylation <532117255@qq.com>
  • Loading branch information
H3mul and Acylation authored Nov 6, 2024
1 parent 02ff7cc commit 1131c57
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/ui/views/Board/BoardView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@
const handleRecordCheck =
(checkField: string): OnRecordCheck =>
(record) => {
(record, checked) => {
api.updateRecord(
updateRecordValues(record, {
[checkField]: !record.values[checkField],
[checkField]: checked,
}),
fields
);
Expand Down
10 changes: 4 additions & 6 deletions src/ui/views/Board/components/Board/CardList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
export let onDrop: OnRecordDrop;
export let includeFields: DataField[];
export let checkField: string | undefined;
const checked = (item: DataRecord): boolean =>
checkField ? (item.values[checkField] as boolean) : false;
export let customHeader: DataField | undefined;
export let boardEditing: boolean;
Expand Down Expand Up @@ -103,10 +101,10 @@
{#if checkField}
<span class="checkbox-wrapper">
<Checkbox
checked={checked(item)}
on:check={() => {
onRecordCheck(item);
}}
checked={checkField !== undefined
? !!item.values[checkField]
: false}
on:check={({ detail: checked }) => onRecordCheck(item, checked)}
/>
</span>
{/if}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/views/Board/components/Board/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export type Column = {
};

export type OnRecordClick = (record: DataRecord) => void;
export type OnRecordCheck = (record: DataRecord) => void;
export type OnRecordCheck = (record: DataRecord, checked: boolean) => void;
export type OnRecordAdd = (column: string) => void;
export type OnRecordDrop = (
record: DataRecord,
Expand Down
8 changes: 4 additions & 4 deletions src/ui/views/Calendar/CalendarView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@
}
}
function handleRecordCheck(record: DataRecord) {
function handleRecordCheck(record: DataRecord, checked: boolean) {
if (booleanField) {
api.updateRecord(
updateRecordValues(record, {
[booleanField.name]: !record.values[booleanField.name],
[booleanField.name]: checked,
}),
fields
);
Expand Down Expand Up @@ -272,8 +272,8 @@
onRecordChange={(record) => {
handleRecordChange(date, record);
}}
onRecordCheck={(record) => {
handleRecordCheck(record);
onRecordCheck={(record, checked) => {
handleRecordCheck(record, checked);
}}
onRecordAdd={() => {
handleRecordAdd(date);
Expand Down
2 changes: 1 addition & 1 deletion src/ui/views/Calendar/components/Calendar/Day.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/**
* onRecordCheck runs when the user Checks / Unchecks a calendar event.
*/
export let onRecordCheck: (record: DataRecord) => void;
export let onRecordCheck: (record: DataRecord, checked: boolean) => void;
/**
* onRecordChange runs when the user changes the checked state.
Expand Down
6 changes: 2 additions & 4 deletions src/ui/views/Calendar/components/Calendar/EventList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
export let checkField: string | undefined;
export let onRecordClick: (record: DataRecord) => void;
export let onRecordCheck: (record: DataRecord) => void;
export let onRecordCheck: (record: DataRecord, checked: boolean) => void;
export let onRecordChange: (record: DataRecord) => void;
function asOptionalBoolean(value: Optional<DataValue>): Optional<boolean> {
Expand Down Expand Up @@ -62,9 +62,7 @@
checked={checkField !== undefined
? asOptionalBoolean(record.values[checkField])
: undefined}
on:check={() => {
onRecordCheck(record);
}}
on:check={({ detail: checked }) => onRecordCheck(record, checked)}
>
<InternalLink
linkText={record.id}
Expand Down

0 comments on commit 1131c57

Please sign in to comment.