fix bug
This commit is contained in:
@@ -55,11 +55,11 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { ref, watch } from 'vue'
|
||||
import {
|
||||
formatSupportMessengers,
|
||||
parseSelectOptions,
|
||||
parseSupportMessengers,
|
||||
parseSupportMessengersDraft,
|
||||
supportMessengerIdPlaceholder,
|
||||
type SupportMessengerEntryDraft,
|
||||
} from './settingTypes'
|
||||
@@ -74,26 +74,29 @@ const props = withDefaults(
|
||||
|
||||
const emit = defineEmits<{ 'update:value': [value: string] }>()
|
||||
|
||||
const messengerOptions = computed(() =>
|
||||
parseSelectOptions({
|
||||
key: 'support_messenger',
|
||||
description: 'bale,telegram,whatsapp,rubika,eitaa,soroush',
|
||||
type: 'select',
|
||||
}),
|
||||
)
|
||||
|
||||
const rows = computed<SupportMessengerEntryDraft[]>({
|
||||
get() {
|
||||
const parsed = parseSupportMessengers(props.modelValue)
|
||||
if (parsed.length > 0) return parsed
|
||||
return [{ messenger: 'bale', id: '' }]
|
||||
},
|
||||
set(nextRows) {
|
||||
emit('update:value', formatSupportMessengers(nextRows))
|
||||
},
|
||||
const messengerOptions = parseSelectOptions({
|
||||
key: 'support_messenger',
|
||||
description: 'bale,telegram,whatsapp,rubika,eitaa,soroush',
|
||||
type: 'select',
|
||||
})
|
||||
|
||||
const rows = ref<SupportMessengerEntryDraft[]>(parseSupportMessengersDraft(props.modelValue))
|
||||
let skipExternalSync = false
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(value) => {
|
||||
if (skipExternalSync) {
|
||||
skipExternalSync = false
|
||||
return
|
||||
}
|
||||
rows.value = parseSupportMessengersDraft(value)
|
||||
},
|
||||
)
|
||||
|
||||
function commit(nextRows: SupportMessengerEntryDraft[]) {
|
||||
rows.value = nextRows
|
||||
skipExternalSync = true
|
||||
emit('update:value', formatSupportMessengers(nextRows))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user