Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unnecessary structuredClone() call, simplify SortActions #1410

Merged
merged 1 commit into from
Jan 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions src/view/plugin/sort/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
multi?: boolean,
compare?: Comparator<TCell>,
) =>
(state) => {
let columns = state.sort ? structuredClone(state.sort.columns) : [];
let columns = state.sort?.columns

Check warning on line 11 in src/view/plugin/sort/actions.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 11 in src/view/plugin/sort/actions.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 11 in src/view/plugin/sort/actions.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 11 in src/view/plugin/sort/actions.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
? state.sort.columns.map((x) => {

Check warning on line 12 in src/view/plugin/sort/actions.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
return { ...x };

Check warning on line 13 in src/view/plugin/sort/actions.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
})

Check warning on line 14 in src/view/plugin/sort/actions.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
: [];

Check warning on line 15 in src/view/plugin/sort/actions.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 15 in src/view/plugin/sort/actions.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
const count = columns.length;
const column = columns.find((x) => x.index === index);
const exists = column !== undefined;
Expand Down Expand Up @@ -85,24 +89,24 @@
};

Check warning on line 89 in src/view/plugin/sort/actions.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

export const SortToggle =
(index: number, multi: boolean, compare?: Comparator<TCell>) => (state) => {
const columns = state.sort ? structuredClone(state.sort.columns) : [];
const columns = state.sort ? [...state.sort.columns] : [];

Check warning on line 93 in src/view/plugin/sort/actions.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 93 in src/view/plugin/sort/actions.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 93 in src/view/plugin/sort/actions.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
const column = columns.find((x) => x.index === index);

if (!column) {
return {
...state,
...SortColumn(index, 1, multi, compare)(state),
};
} else {
return {
...state,
...SortColumn(
index,
column.direction === 1 ? -1 : 1,
multi,
compare,
)(state),
};
}

return {
...state,
...SortColumn(
index,
column.direction === 1 ? -1 : 1,

Check warning on line 107 in src/view/plugin/sort/actions.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 107 in src/view/plugin/sort/actions.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
multi,
compare,
)(state),

Check warning on line 110 in src/view/plugin/sort/actions.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
};
};

Check warning on line 112 in src/view/plugin/sort/actions.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
Loading