@@ -28,7 +28,6 @@ interface Turnstile {
2828 " error-callback" ? : (error : string ) => void ;
2929 },
3030 ): string | null | undefined ;
31- reset(widgetId ? : string ): void ;
3231 remove(widgetId ? : string ): void ;
3332}
3433
@@ -66,7 +65,6 @@ const messages = ref<EntitiesMessage[]>([]);
6665const totalMessages = ref (0 );
6766const selectedIds = ref <string []>([]);
6867let turnstileWidgetId: string | null = null ;
69- let captchaPromise: Promise <string > | null = null ;
7068
7169const page = ref (1 );
7270const itemsPerPage = ref (100 );
@@ -127,51 +125,23 @@ const messageStatusSelectItems = [
127125];
128126
129127function getCaptcha(): Promise <string > {
130- if (captchaPromise ) {
131- return captchaPromise ;
132- }
133-
134- captchaPromise = new Promise <string >((resolve , reject ) => {
135- const turnstile = (window as unknown as { turnstile? : Turnstile })
136- .turnstile ;
137- if (! turnstile ) {
138- resolve (" " );
139- return ;
140- }
141-
142- const resetPromise = () => {
143- captchaPromise = null ;
144- };
145-
128+ return new Promise <string >((resolve , reject ) => {
129+ const turnstile: Turnstile = (window as unknown as { turnstile? : Turnstile }).turnstile ! ;
146130 turnstile .ready (() => {
147- const complete = (token : string ) => {
148- resetPromise ();
149- resolve (token );
150- };
151- const fail = (error : string ) => {
152- resetPromise ();
153- reject (error );
154- };
155-
156131 if (turnstileWidgetId ) {
157- turnstile .reset (turnstileWidgetId );
158- return ;
132+ turnstile .remove (turnstileWidgetId );
133+ turnstileWidgetId = null ;
159134 }
160135
161- turnstileWidgetId =
162- turnstile .render (" #cloudflare-turnstile" , {
136+ turnstileWidgetId = turnstile .render (" #cloudflare-turnstile" , {
163137 sitekey: (config .public as Record <string , string >)
164138 .cloudflareTurnstileSiteKey ! ,
165139 action: " search_messages" ,
166- callback: complete ,
167- " error-callback" : fail ,
140+ callback : ( token ) => resolve ( token ) ,
141+ " error-callback" : ( error : string ) => reject ( error ) ,
168142 }) ?? null ;
169143 });
170144 });
171-
172- return captchaPromise .finally (() => {
173- captchaPromise = null ;
174- });
175145}
176146
177147function parseErrors(error : any ): ErrorMessages {
@@ -214,7 +184,7 @@ async function fetchMessages(reset = false) {
214184 }
215185 } catch (error : any ) {
216186 errorTitle .value = capitalize (
217- error ?.data ?.message ?? " Error while searching messages" ,
187+ error ?.data ?.message ?? " Error while searching messages. Contact us via email "
218188 );
219189 errorMessages .value = parseErrors (error );
220190 } finally {
@@ -393,7 +363,7 @@ onBeforeUnmount(() => {
393363 <VContainer >
394364 <VRow >
395365 <VCol cols="12">
396- <h5 class =" text-headline-large mb-3 mt-3 " >Search Messages</h5 >
366+ <h5 class =" text-headline-large mb-3 mt-0 " >Search Messages</h5 >
397367 <p >
398368 On this page, you can search all your messages by phone number,
399369 message type, and message status and even using the content of the
0 commit comments