-
Notifications
You must be signed in to change notification settings - Fork 3
fix state manager #50
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
Conversation
…sion into fix-state-manager
|
Update:
cc: @foxish |
foxish
left a comment
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.
I see the intent behind the refactor and the separation of the storage this way makes sense, but I had several comments along the way.
| useEffect(() => { | ||
| refetch(); | ||
| }, [apiUrl]); | ||
| }, [settings.signadotUrls.apiUrl]); |
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.
Maybe a separate follow-up issue, but I'd expect this to be refetched if the org name changes as well (someone logs into different org)
src/service-worker.ts
Outdated
|
|
||
| await chrome.storage.local.set({[StorageKey.InjectedHeaders]: headerKeys}); | ||
| const { routingKey, enabled, headers, traceparentHeader } = values; | ||
| const injectHeaders = headers.length > 0 && enabled && routingKey; |
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.
Given the default headers, we don't ever expect headers.length be 0 right?
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.
Yes, we expect in the case of not being enabled in the react side, we set to empty array.
|
|
||
| // Signadot URLs | ||
| if (storedValues[StorageBrowserKeys.signadotUrls] !== undefined) { | ||
| try { |
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.
Can we do this without the try...catch? If this is our code, can't we check for whether it's present using if..else rather than throwing and catching exceptions?
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.
JSON.parse could trigger an error if it's not a valid JSON or it's malformed. In any case i think it's a good practice to in case of error, set the default. Cause this could be user prune if they updated by hand, or for some reason value is corrupted. Or if between version and version we decide to change the schema
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.
Okay. fair, but let's catch specific exceptions with JSON parsing using instanceof - that will at least ensure we don't hide errors that are unrelated and behave in surprising ways.
src/components/Settings/Settings.tsx
Outdated
| const [previewUrl, setPreviewUrl] = useState<string>(DEFAULT_PREVIEW_URL); | ||
| const [dashboardUrl, setDashboardUrl] = useState<string>(DEFAULT_DASHBOARD_URL); | ||
| const [traceparentHeader, setTraceparentHeader] = useState<string>(DEFAULT_TRACEPARENT_HEADER); | ||
| const [temporaryValues, setTemporaryValues] = useState<{ |
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.
What is a temporaryValue is and what purpose does this serve?
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.
Maybe unsavedValues? This is working as temporary values that are yet not saved
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.
unsavedValues sgtm
src/components/Settings/Settings.tsx
Outdated
|
|
||
| setTraceparent(temporaryValues.traceparentHeaderEnabled, temporaryValues.traceparentHeader); | ||
|
|
||
| // chrome.storage.local.set({ |
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.
Please add a code comment explaining why this is commented out
I accidentally applyed the prettier to all the files. So there are bunch of changes, but primarly you should focus on - Route - ProtectedRoute - AuthContext - Frame - Layout This fixes some inconsistences on the unauthenticated state, blocking the access in some cases, where now it's being fixed thanks to the RouteView context
|
@foxish major and minor fixes are been applied, any issue that is not state should be tackled separelty. Things that remains is to test traceparent is being updated correctly and injected when it should. Similar to the others headers to be injected only when
Tested on a fresh installation |
foxish
left a comment
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.
LGTM, it got messy and too large, in future, please plan ahead so that the complicated changes can be merged separately and the stylistic stuff can happen later.
This change is not correct - but can be addressed in follow-up PR - the search should come up on top and also when nothing is selected, it's cutting off the dropdown.
|
That issue is being addressed in #51 |



This is break currently, but with this refactor i expect to fix multiple issues related to stata manager including
#44 and one that was reported today
Error updating dynamic rules: Error: Rule with id 1 does not have a unique ID.I think that refactor should improve the speed a little bit cause it will prevent some duplicate calls that are triggered on the service worker