Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@

export async function submit() {
try {
if (!option?.update) {
throw new Error('Unsupported column type');
}
await option.update(databaseId, tableId, selectedColumn, originalKey);
await invalidate(Dependencies.TABLE);

Expand Down Expand Up @@ -103,7 +106,7 @@

// TODO: @itznotabug - runes?
$: onShow(showEdit);
$: title = `Update ${columnOptions.find((v) => v.name === option.name)?.sentenceName ?? ''} column`;
$: title = `Update ${option ? (columnOptions.find((v) => v.name === option.name)?.sentenceName ?? '') : ''} column`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Redundant find when option is already the matched entry

When option is defined, it is already the result of columnOptions.find(...), so searching columnOptions a second time by option.name to get sentenceName is redundant — you can read option.sentenceName directly. This simplifies the expression and avoids a linear scan:

Suggested change
$: title = `Update ${option ? (columnOptions.find((v) => v.name === option.name)?.sentenceName ?? '') : ''} column`;
$: title = `Update ${option?.sentenceName ?? ''} column`;


function onShow(show: boolean) {
if (show) {
Expand Down