-
Notifications
You must be signed in to change notification settings - Fork 1
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
[MOC-56] waiting until update finishes before showing rec list #70
Changes from 2 commits
5274d5c
68c41b7
97abe78
fb61a03
64ff21a
6317e68
807175d
701f74c
3aad6fd
059e284
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,12 +70,17 @@ export const saveModification = ( | |
saveModificationCommand.execute(); | ||
}; | ||
|
||
export const persistModifications = (recordingId: string) => { | ||
export const persistModifications = async (recordingId: string) => { | ||
const alterations: Alteration[] = buildAlterations(domainModifications); | ||
chrome.storage.local.set({ | ||
[MOCKSI_MODIFICATIONS]: JSON.stringify(domainModifications), | ||
}); | ||
const updated_timestamp = new Date(); | ||
await updateRecordingsStorage({ | ||
uuid: recordingId, | ||
updated_timestamp, | ||
alterations, | ||
}); | ||
sendMessage("updateDemo", { | ||
id: recordingId, | ||
recording: { updated_timestamp, alterations }, | ||
|
@@ -264,3 +269,27 @@ export const getRecordingsStorage = async (): Promise<Recording[]> => { | |
throw err; | ||
} | ||
}; | ||
|
||
export const updateRecordingsStorage = async ({ | ||
uuid, | ||
updated_timestamp, | ||
alterations, | ||
}: { uuid: string; updated_timestamp: Date; alterations: Alteration[] }) => { | ||
try { | ||
const recordingsFromStorage = await getRecordingsStorage(); | ||
const modifiedRecordings = recordingsFromStorage.map((recording) => | ||
recording.uuid === uuid | ||
? { ...recording, uuid, updated_timestamp, alterations } | ||
: recording, | ||
); | ||
const sorted = modifiedRecordings.sort((a: Recording, b: Recording) => | ||
a.updated_timestamp > b.updated_timestamp ? -1 : 0, | ||
); | ||
const recordingsStringified = JSON.stringify(sorted); | ||
console.log("modified", recordingsFromStorage, sorted); | ||
chrome.storage.local.set({ recordings: recordingsStringified }); | ||
} catch (err) { | ||
console.error("Failed to save modifications from LS:", err); | ||
throw err; | ||
} | ||
}; | ||
Comment on lines
+282
to
+304
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tip Codebase Verification Unit tests for The search results indicate that the
Analysis chainNew Feature: Added This addition is significant as it centralizes the logic for updating recordings in storage, which can improve maintainability and testing. The function also handles errors robustly, which is crucial for reliability. Ensure that this function is covered by unit tests to verify its behavior under various scenarios. Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Verify if unit tests cover the new `updateRecordingsStorage` function.
rg --type typescript -g '*test.ts' 'updateRecordingsStorage'
Length of output: 95 Script: #!/bin/bash
# Verify if unit tests cover the new `updateRecordingsStorage` function.
rg --type ts -g '*test.ts' 'updateRecordingsStorage'
Length of output: 52 Script: #!/bin/bash
# Find all test files in the repository
fd --type f --extension ts --exec rg 'updateRecordingsStorage' {}
Length of output: 148 Script: #!/bin/bash
# Find all test files in the repository and their occurrences of `updateRecordingsStorage`
fd --type f --extension ts --exec rg --with-filename --line-number 'updateRecordingsStorage' {}
Length of output: 241 |
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.
Tip
Codebase Verification
Unit tests are missing for the
onKeyUp
event handler inContentApp.tsx
.To ensure the new logic is thoroughly tested, please add unit tests for the
onKeyUp
event handler inContentApp.tsx
. This will help verify thatsetEditorMode
andonChangeState
are correctly called afterloadRecordingId
.onKeyUp
event handler inapps/mocksi-lite/content/ContentApp.tsx
.Analysis chain
Refactor: Modified
onKeyUp
event handler for "Enter" key.This change ensures that
setEditorMode
andonChangeState
are called afterloadRecordingId
, which is crucial for ensuring that the application's state is consistent with the backend data. This is a critical change and should be thoroughly tested.Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 79
Script:
Length of output: 36
Script:
Length of output: 999