refactor: convert snapshot to a solid store (@miodec)#7373
refactor: convert snapshot to a solid store (@miodec)#7373
Conversation
|
Continuous integration check(s) failed. Please review the failing check's logs and make the necessary changes. |
There was a problem hiding this comment.
Pull request overview
This PR refactors the snapshot management system to use a Solid.js store instead of direct variable access. The refactor changes how the application accesses and modifies user data stored in the snapshot, converting from a mutable module-level variable to an immutable store pattern.
Changes:
- Replaced the module-level
dbSnapshotvariable with a Solid.js store implementation usingcreateStore - Modified
getSnapshot()to return a deep clone of the unwrapped store data - Updated
setSnapshot()to use the store setter and properly handle undefined snapshots - Migrated
testActivity(calendar object) totestActivityData(raw data), creating calendar instances on-demand
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
frontend/src/ts/db.ts |
Implements Solid.js store for snapshot management, updates all functions to call getSnapshot() and setSnapshot() appropriately, migrates testActivity to testActivityData |
frontend/src/ts/constants/default-snapshot.ts |
Updates Snapshot type definition to replace testActivity with testActivityData |
frontend/src/ts/pages/account.ts |
Caches snapshot at function scope to avoid multiple calls to getSnapshot(), uses testActivityData instead of testActivity |
frontend/src/ts/elements/test-activity.ts |
Updates to accept testActivityData and creates calendar instance locally |
frontend/src/ts/elements/test-activity-calendar.ts |
Adds getRawData() method to convert calendar back to raw data format |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Continuous integration check(s) failed. Please review the failing check's logs and make the necessary changes. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
frontend/src/ts/elements/test-activity-calendar.ts:239
- The
lastDayfield is already initialized in the parent class constructor at line 49, then re-initialized here at line 238. This duplicate initialization is unnecessary since the parent constructor already setsthis.lastDay = new UTCDateMini(lastDay). Remove line 238 to avoid redundant initialization.
constructor(data: (number | null)[], lastDay: Date, firstDayOfWeek: Day) {
super(data, lastDay, firstDayOfWeek);
this.lastDay = new UTCDateMini(lastDay);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.