Skip to content

Commit 49810e2

Browse files
committed
add action to turnstile
1 parent d9f5c3a commit 49810e2

File tree

1 file changed

+40
-32
lines changed

1 file changed

+40
-32
lines changed

web/pages/search-messages/index.vue

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ interface Turnstile {
301301
container: string | HTMLElement,
302302
params?: {
303303
sitekey: string
304+
action: string
304305
callback?: (token: string) => void
305306
'error-callback'?: ((error: string) => void) | undefined
306307
},
@@ -408,6 +409,7 @@ export default Vue.extend({
408409
callback: (token) => {
409410
resolve(token)
410411
},
412+
action: 'search_messages',
411413
'error-callback': (error: string) => {
412414
reject(error)
413415
},
@@ -485,38 +487,44 @@ export default Vue.extend({
485487
this.options.page = 1
486488
}
487489
488-
this.getCaptcha().then((token: string) => {
489-
this.$store
490-
.dispatch('searchMessages', {
491-
token,
492-
owners: this.formOwners,
493-
types: this.formTypes,
494-
statuses: this.formStatuses,
495-
query: this.formQuery,
496-
sort_by: this.options.sortBy[0],
497-
sort_descending: this.options.sortDesc[0],
498-
skip: (this.options.page - 1) * this.options.itemsPerPage,
499-
limit: this.options.itemsPerPage,
500-
} as SearchMessagesRequest)
501-
.then((messages: EntitiesMessage[]) => {
502-
this.messages = messages
503-
this.totalMessages =
504-
(this.options.page - 1) * this.options.itemsPerPage +
505-
messages.length
506-
if (messages.length === this.options.itemsPerPage) {
507-
this.totalMessages = this.totalMessages + 1
508-
}
509-
})
510-
.catch((error: AxiosError<ResponsesUnprocessableEntity>) => {
511-
this.errorTitle = capitalize(
512-
error.response?.data?.message ?? 'Error while searching messages',
513-
)
514-
this.errorMessages = getErrorMessages(error)
515-
})
516-
.finally(() => {
517-
this.loading = false
518-
})
519-
})
490+
this.getCaptcha()
491+
.then((token: string) => {
492+
this.$store
493+
.dispatch('searchMessages', {
494+
token,
495+
owners: this.formOwners,
496+
types: this.formTypes,
497+
statuses: this.formStatuses,
498+
query: this.formQuery,
499+
sort_by: this.options.sortBy[0],
500+
sort_descending: this.options.sortDesc[0],
501+
skip: (this.options.page - 1) * this.options.itemsPerPage,
502+
limit: this.options.itemsPerPage,
503+
} as SearchMessagesRequest)
504+
.then((messages: EntitiesMessage[]) => {
505+
this.messages = messages
506+
this.totalMessages =
507+
(this.options.page - 1) * this.options.itemsPerPage +
508+
messages.length
509+
if (messages.length === this.options.itemsPerPage) {
510+
this.totalMessages = this.totalMessages + 1
511+
}
512+
})
513+
.catch((error: AxiosError<ResponsesUnprocessableEntity>) => {
514+
this.errorTitle = capitalize(
515+
error.response?.data?.message ??
516+
'Error while searching messages',
517+
)
518+
this.errorMessages = getErrorMessages(error)
519+
})
520+
.finally(() => {
521+
this.loading = false
522+
})
523+
})
524+
.catch((error: string) => {
525+
this.errorTitle = error
526+
this.loading = false
527+
})
520528
},
521529
},
522530
})

0 commit comments

Comments
 (0)