Skip to content

Commit 99dfbbd

Browse files
committed
Refactor checkpoint starring logic to use the new toggle_checkpoint_star action for cleaner command implementation
1 parent fcce556 commit 99dfbbd

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

packages/vscode/src/commands/checkpoints-command/checkpoints-command.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {
1212
clear_all_checkpoints,
1313
delete_checkpoint,
1414
get_checkpoints,
15-
restore_checkpoint
15+
restore_checkpoint,
16+
toggle_checkpoint_star
1617
} from './actions'
1718
import { PanelProvider } from '@/views/panel/backend/panel-provider'
1819
import { get_checkpoint_path } from './utils'
@@ -309,17 +310,12 @@ export const checkpoints_command = (params: {
309310
if (!item.checkpoint) return
310311

311312
if (e.button.tooltip == 'Star' || e.button.tooltip == 'Unstar') {
312-
const checkpoint_to_update = checkpoints.find(
313-
(c) => c.timestamp == item.checkpoint?.timestamp
314-
)
315-
if (checkpoint_to_update) {
316-
checkpoint_to_update.is_starred = !checkpoint_to_update.is_starred
317-
await params.context.workspaceState.update(
318-
CHECKPOINTS_STATE_KEY,
319-
checkpoints
320-
)
321-
params.panel_provider.send_checkpoints()
322-
}
313+
await toggle_checkpoint_star({
314+
context: params.context,
315+
timestamp: item.checkpoint.timestamp,
316+
panel_provider: params.panel_provider
317+
})
318+
323319
await refresh_and_update_view()
324320
const active_item = quick_pick.items.find(
325321
(i) =>

0 commit comments

Comments
 (0)