From 8dd49d3a8c1c0b4c408f5530a80fa0c8ef8e0fd7 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sat, 28 Jan 2023 19:17:04 +0100 Subject: [PATCH 1/2] Remove author search handler --- app/javascript/retrospring/features/inbox/author.ts | 6 ------ app/javascript/retrospring/features/inbox/index.ts | 3 +-- 2 files changed, 1 insertion(+), 8 deletions(-) delete mode 100644 app/javascript/retrospring/features/inbox/author.ts diff --git a/app/javascript/retrospring/features/inbox/author.ts b/app/javascript/retrospring/features/inbox/author.ts deleted file mode 100644 index 456b0ed5..00000000 --- a/app/javascript/retrospring/features/inbox/author.ts +++ /dev/null @@ -1,6 +0,0 @@ -export function authorSearchHandler(event: Event): void { - event.preventDefault(); - - const author = document.querySelector('#author')?.value; - window.location.href = `/inbox/${encodeURIComponent(author)}`; -} \ No newline at end of file diff --git a/app/javascript/retrospring/features/inbox/index.ts b/app/javascript/retrospring/features/inbox/index.ts index 4235dc15..02206e9a 100644 --- a/app/javascript/retrospring/features/inbox/index.ts +++ b/app/javascript/retrospring/features/inbox/index.ts @@ -6,8 +6,7 @@ import { deleteAllAuthorQuestionsHandler, deleteAllQuestionsHandler } from './de export default (): void => { registerEvents([ { type: 'click', target: '#ib-delete-all', handler: deleteAllQuestionsHandler, global: true }, - { type: 'click', target: '#ib-delete-all-author', handler: deleteAllAuthorQuestionsHandler, global: true }, - { type: 'submit', target: '#author-form', handler: authorSearchHandler, global: true } + { type: 'click', target: '#ib-delete-all-author', handler: deleteAllAuthorQuestionsHandler, global: true } ]); registerInboxEntryEvents(); From 6c25594b88b68eea1b442c8b2553718380731717 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sat, 28 Jan 2023 19:18:02 +0100 Subject: [PATCH 2/2] Get the username of the currently searched author correctly --- app/javascript/retrospring/features/inbox/delete.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/javascript/retrospring/features/inbox/delete.ts b/app/javascript/retrospring/features/inbox/delete.ts index 6595af0b..c93534b2 100644 --- a/app/javascript/retrospring/features/inbox/delete.ts +++ b/app/javascript/retrospring/features/inbox/delete.ts @@ -62,6 +62,7 @@ export function deleteAllQuestionsHandler(event: Event): void { export function deleteAllAuthorQuestionsHandler(event: Event): void { const button = event.target as Element; const count = button.getAttribute('data-ib-count'); + const urlSearchParams = new URLSearchParams(window.location.search); swal({ title: I18n.translate('frontend.inbox.confirm_all.title', { count: count }), @@ -75,7 +76,7 @@ export function deleteAllAuthorQuestionsHandler(event: Event): void { }, (returnValue) => { if (returnValue === null) return false; - post(`/ajax/delete_all_inbox/${location.pathname.split('/')[2]}`) + post(`/ajax/delete_all_inbox/${urlSearchParams.get('author')}`) .then(async response => { const data = await response.json; @@ -89,4 +90,4 @@ export function deleteAllAuthorQuestionsHandler(event: Event): void { showErrorNotification(I18n.translate('frontend.error.message')); }); }); -} \ No newline at end of file +}