refactor: merge watch targets, flatten callback (#812)
This commit is contained in:
@@ -18,9 +18,7 @@ onMounted(() => {
|
||||
handleAnalyze()
|
||||
})
|
||||
|
||||
watch(() => props.stream, () => {
|
||||
handleAnalyze()
|
||||
})
|
||||
watch(() => props.stream, handleAnalyze)
|
||||
|
||||
function handleAnalyze() {
|
||||
if (!props.stream) {
|
||||
|
||||
@@ -42,10 +42,9 @@ function scrollToBottom() {
|
||||
})
|
||||
}
|
||||
|
||||
watch(() => props.messages, () => scrollToBottom(), { deep: true, flush: 'post' })
|
||||
watch(() => props.streamingMessage, () => scrollToBottom(), { deep: true, flush: 'post' })
|
||||
watch(() => props.sending, () => scrollToBottom(), { flush: 'post' })
|
||||
onMounted(() => scrollToBottom())
|
||||
watch([() => props.messages, () => props.streamingMessage], scrollToBottom, { deep: true, flush: 'post' })
|
||||
watch(() => props.sending, scrollToBottom, { flush: 'post' })
|
||||
onMounted(scrollToBottom)
|
||||
|
||||
const streaming = computed<ChatAssistantMessage>(() => props.streamingMessage ?? { role: 'assistant', content: '', slices: [], tool_results: [] })
|
||||
const showStreamingPlaceholder = computed(() => (streaming.value.slices?.length ?? 0) === 0 && !streaming.value.content)
|
||||
|
||||
+1
-3
@@ -37,9 +37,7 @@ function initializeForm() {
|
||||
}
|
||||
|
||||
// Watch for provider changes
|
||||
watch(() => context.selectedProvider.value?.id, () => {
|
||||
initializeForm()
|
||||
})
|
||||
watch(() => context.selectedProvider.value?.id, initializeForm)
|
||||
|
||||
// Computed properties
|
||||
const needsApiKey = computed(() => {
|
||||
|
||||
@@ -65,8 +65,7 @@ function handleResize() {
|
||||
// The CSS styles handle the display size, so we don't need to manually set view dimensions
|
||||
}
|
||||
|
||||
watch([() => props.width, () => props.height], () => handleResize())
|
||||
watch(() => props.resolution, () => handleResize())
|
||||
watch([() => props.width, () => props.height, () => props.resolution], handleResize)
|
||||
|
||||
onMounted(async () => containerRef.value && await initLive2DPixiStage(containerRef.value))
|
||||
onUnmounted(() => pixiApp.value?.destroy())
|
||||
|
||||
@@ -393,7 +393,7 @@ function updateDropShadowFilter() {
|
||||
model.value.filters = [dropShadowFilter.value]
|
||||
}
|
||||
|
||||
watch([() => props.width, () => props.height], () => handleResize())
|
||||
watch([() => props.width, () => props.height], handleResize)
|
||||
watch(modelSrcRef, async () => await loadModel(), { immediate: true })
|
||||
watch(dark, updateDropShadowFilter, { immediate: true })
|
||||
watch([model, themeColorsHue], updateDropShadowFilter)
|
||||
|
||||
Reference in New Issue
Block a user