-
Notifications
You must be signed in to change notification settings - Fork 156
Refactor: Replace jQuery with Vue reactivity in OpenOffline.vue #487
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request refactors the close functionality in the Changes
Sequence Diagram(s)sequenceDiagram
participant User as User
participant Component as OpenOffline.vue
participant State as SimulatorState
User->>Component: Click "Open Project" / "Import Project" button
Component->>Component: Execute openProjectOffline() / OpenImportProjectDialog()
Component->>Component: Invoke closeDialog()
Component->>State: Set dialogBox.open_project_dialog = false
Note over Component: watchEffect refreshes projectList when dialog opens
Possibly related PRs
Suggested labels
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for circuitverse ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/components/DialogBox/OpenOffline.vue (2)
100-100
: Consider consistent function naming.The function
OpenImportProjectDialog
should follow camelCase naming convention to be consistent with other functions likeopenProjectOffline
.-function OpenImportProjectDialog() { +function openImportProjectDialog() {
81-88
: Consider adding type safety improvements.The functions could benefit from explicit return types and error handling for localStorage operations.
-function deleteOfflineProject(id: string) { +function deleteOfflineProject(id: string): void { try { localStorage.removeItem(id) const data = localStorage.getItem('projectList') const temp = data ? JSON.parse(data) : {} delete temp[id] projectList.value = temp localStorage.setItem('projectList', JSON.stringify(temp)) + } catch (error) { + console.error('Failed to delete offline project:', error) + } } -function openProjectOffline() { +function openProjectOffline(): void { closeDialog(); if (!selectedProjectId.value) return + try { const projectData = localStorage.getItem(selectedProjectId.value) if (projectData) { load(JSON.parse(projectData)) window.projectId = selectedProjectId.value } + } catch (error) { + console.error('Failed to open offline project:', error) + } }Also applies to: 90-98
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/components/DialogBox/OpenOffline.vue
(5 hunks)
🔇 Additional comments (4)
src/components/DialogBox/OpenOffline.vue (4)
13-13
: LGTM! Improved dialog close handling.Centralizing the close logic in a dedicated function improves code maintainability.
35-35
: LGTM! Better empty object checks.Using
Object.keys(projectList).length
is a more idiomatic and performant way to check for empty objects compared to JSON string comparison.Also applies to: 43-43
71-76
: LGTM! Improved reactivity with watchEffect.Using
watchEffect
to update the project list when the dialog opens is a more elegant solution than using lifecycle hooks. This ensures the list is always fresh when needed.
77-79
: LGTM! Clean function implementation.The
closeDialog
function follows the single responsibility principle and centralizes the dialog closing logic.
@JoshVarga @Arnabdaz PTAL |
Fixes #433
cc : @Arnabdaz @JoshVarga
Note: Please check Allow edits from maintainers. if you would like us to assist in the PR.
Summary by CodeRabbit