-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix: chat avatar display problem #2749
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 |
---|---|---|
|
@@ -693,6 +693,9 @@ function getDetail() { | |
applicationForm.value.tts_type = res.data.tts_type | ||
applicationForm.value.model_setting.no_references_prompt = | ||
res.data.model_setting.no_references_prompt || '{question}' | ||
application.asyncGetAccessToken(id, loading).then((res: any) => { | ||
applicationForm.value = { ...applicationForm.value, ...res.data } | ||
}) | ||
}) | ||
} | ||
|
||
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 code looks generally fine but has a few areas that can be improved:
Here’s an optimized version of the code with these improvements: function getDetail() {
applicationForm.value.tts_type = res.data.tts_type;
// Use ? for optional chaining to safely access object properties
const noReferencesPrompt = res.data.model_setting?.no_references_prompt || '{question}';
applicationForm.value.model_setting.no_references_prompt = noReferencesPrompt;
// Use async/await for cleaner error handling
try {
const accessTokenResponse = await application.asyncGetAccessToken(id);
// Merge the returned data into applicationForm using spread operator
Object.assign(applicationForm.value, accessTokenResponse.data);
} catch (error) {
console.error('Error fetching access token:', error);
}
} Key Changes:
|
||
|
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 is mostly correct but has a few minor improvements that can be made:
Consistent Return Value Handling: The
application.asyncGetAccessToken
promise returns an object with properties likestatus
and possibly other attributes instead ofdata
. You may want to handle this more appropriately.Optimize Next Tick Execution: Since you're calling
nextTick()
synchronously after clearing the graph data, it might not improve performance much unless there's significant work being done in the template rendering phase. Consider moving this toworkflowRef.value?.render(detail.value.work_flow)
directly insidenextTick
.Type Annotations: While TypeScript annotations aren't necessary in modern JavaScript, they help catch potential errors related to type mismatches during development. Ensure all variables are properly typed.
Here’s the slightly optimized version:
These changes enhance readability and consistency while addressing some common practices for handling asynchronous operations better.