5959 close-after-click
6060 @click =" showTaskList = true" >
6161 <template #icon >
62- <NcAssistantIcon :size =" 20" class =" assistant-icon" />
62+ <NcLoadingIcon v-if =" loading" :size =" 20" />
63+ <NcAssistantIcon v-else :size =" 20" class =" assistant-icon" />
6364 </template >
6465 {{ t('text', 'Show assistant results') }}
6566 </NcActionButton >
@@ -161,6 +162,7 @@ import NcActions from '@nextcloud/vue/components/NcActions'
161162import NcActionSeparator from ' @nextcloud/vue/components/NcActionSeparator'
162163import NcAssistantIcon from ' @nextcloud/vue/components/NcAssistantIcon'
163164import NcListItem from ' @nextcloud/vue/components/NcListItem'
165+ import NcLoadingIcon from ' @nextcloud/vue/components/NcLoadingIcon'
164166import NcModal from ' @nextcloud/vue/components/NcModal'
165167import ErrorOutlineIcon from ' vue-material-design-icons/AlertCircleOutline.vue'
166168import CheckCircleOutlineIcon from ' vue-material-design-icons/CheckCircleOutline.vue'
@@ -206,6 +208,7 @@ export default {
206208 NcActionButton,
207209 NcActionSeparator,
208210 NcListItem,
211+ NcLoadingIcon,
209212 NcModal,
210213 },
211214 extends: BaseActionEntry,
@@ -217,9 +220,10 @@ export default {
217220 data () {
218221 return {
219222 menuOpen: false ,
220- taskTypes: OCP . InitialState . loadState (' text' , ' taskprocessing' ),
223+ taskTypes: loadState (' text' , ' taskprocessing' , [] ),
221224 selection: ' ' ,
222225 tasks: [],
226+ loading: false ,
223227
224228 STATUS_FAILED ,
225229 STATUS_RUNNING ,
@@ -262,9 +266,17 @@ export default {
262266 return this .taskTypes .map ((type ) => type .id )
263267 },
264268 },
269+ watch: {
270+ async menuOpen (isOpen ) {
271+ if (isOpen && this .tasks .length === 0 ) {
272+ this .loading = true
273+ await this .fetchTasks ()
274+ this .loading = false
275+ }
276+ },
277+ },
265278 beforeMount () {
266279 this .editor .on (' selectionUpdate' , this .onSelection )
267- this .fetchTasks ()
268280 subscribe (' notifications:notification:received' , this .checkNotification )
269281 },
270282 beforeDestroy () {
0 commit comments