-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: Historical user conversation data has been cleared #2840
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -65,7 +65,11 @@ const useUserStore = defineStore({ | |
| if (token) { | ||
| return token | ||
| } | ||
| return localStorage.getItem(`${this.userAccessToken}accessToken`) | ||
| const local_token = localStorage.getItem(`${token}accessToken`) | ||
| if (local_token) { | ||
| return local_token | ||
| } | ||
| return localStorage.getItem(`accessToken`) | ||
| }, | ||
|
|
||
| getPermissions() { | ||
|
Contributor
Author
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. The provided code snippet includes some minor issues that can be addressed: Issues Identified:
Optimization Suggestions:
@@ -65,14 +65,16 @@ const useUserStore = defineStore({
let refreshTokenFromStorage
if (refreshToken) {
token = refreshToken
}
- // Fetch access token based on the provided token or 'accessToken' from storage
+ const tokenId = token || 'accessToken'
+
accessTokenFromStorage = localStorage.getItem(`${tokenId}AccessToken`)
return accessTokenFromStorage ? accessTokenFromStorage : ''
+ } else {
+ // Fallback if no valid token is available
+ console.warn('No valid token found.')
+ return ''
}
}
function getPermissions() {By making these changes, the code becomes cleaner, reduces duplication, and improves its legibility and maintainability. |
||
|
|
||
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.
The provided code function
sendMessagecan be optimized and enhanced as follows:Functionality
The function currently handles sending messages with various parameters, including user input and optional loading status. However, there are some areas that could be improved:
Loading Status Handling: The logic for deciding whether to call
handleDebounceClickinvolves checking both theloading.valuecondition andprops.applicationDetails?.name. This redundancy should be removed.Empty Message Validation: It might be beneficial to add a validation step to ensure that the message is not empty before attempting to send it.
Conditional Logic Refinement: The conditional logic around showing user input can be simplified.
Optimization and Recommendations
loading.value && props.applicationDetails?.name.Code Cleanup
Ensure the function is clean and easy to read by following PEP8 guidelines. Here’s an updated version of the function:
In summary, these improvements reduce code duplication, make the logic clearer, and add basic value-validation checks to enhance maintainability and reliability of the function.