From 6a740a8bb96c50b39a00415f3d4d7345c229909a Mon Sep 17 00:00:00 2001 From: plebeius Date: Thu, 8 Jan 2026 17:36:47 +0100 Subject: [PATCH] add approve/reject mod queue functionality, translations --- public/translations/ar/default.json | 5 +- public/translations/bn/default.json | 5 +- public/translations/cs/default.json | 5 +- public/translations/da/default.json | 5 +- public/translations/de/default.json | 5 +- public/translations/el/default.json | 5 +- public/translations/en/default.json | 5 +- public/translations/es/default.json | 5 +- public/translations/fa/default.json | 5 +- public/translations/fi/default.json | 5 +- public/translations/fil/default.json | 5 +- public/translations/fr/default.json | 5 +- public/translations/he/default.json | 5 +- public/translations/hi/default.json | 5 +- public/translations/hu/default.json | 5 +- public/translations/id/default.json | 5 +- public/translations/it/default.json | 5 +- public/translations/ja/default.json | 5 +- public/translations/ko/default.json | 5 +- public/translations/mr/default.json | 5 +- public/translations/nl/default.json | 5 +- public/translations/no/default.json | 5 +- public/translations/pl/default.json | 5 +- public/translations/pt/default.json | 5 +- public/translations/ro/default.json | 5 +- public/translations/ru/default.json | 5 +- public/translations/sq/default.json | 5 +- public/translations/sv/default.json | 5 +- public/translations/te/default.json | 5 +- public/translations/th/default.json | 5 +- public/translations/tr/default.json | 5 +- public/translations/uk/default.json | 5 +- public/translations/ur/default.json | 5 +- public/translations/vi/default.json | 5 +- public/translations/zh/default.json | 5 +- src/views/mod-queue/mod-queue.tsx | 103 +++++++++++++++++++++------ 36 files changed, 223 insertions(+), 55 deletions(-) diff --git a/public/translations/ar/default.json b/public/translations/ar/default.json index 7c0c963b..6a7ea3f8 100644 --- a/public/translations/ar/default.json +++ b/public/translations/ar/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "إظهار مؤشر أحمر وامض عندما تكون العناصر في الانتظار لأكثر من هذا الوقت", "no_content": "لا يوجد محتوى", "view": "عرض", - "excerpt": "مقتطف" + "excerpt": "مقتطف", + "publishing": "نشر", + "approved": "موافق عليه", + "rejected": "مرفوض" } diff --git a/public/translations/bn/default.json b/public/translations/bn/default.json index 6efa3f53..6f93bda4 100644 --- a/public/translations/bn/default.json +++ b/public/translations/bn/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "আইটেমগুলি এই সময়ের চেয়ে বেশি অপেক্ষা করলে একটি ঝলমলে লাল সূচক দেখান", "no_content": "কোনো বিষয়বস্তু নেই", "view": "দেখুন", - "excerpt": "উদ্ধৃতি" + "excerpt": "উদ্ধৃতি", + "publishing": "প্রকাশনা", + "approved": "অনুমোদিত", + "rejected": "প্রত্যাখ্যান" } diff --git a/public/translations/cs/default.json b/public/translations/cs/default.json index 222f6672..fcf2b38d 100644 --- a/public/translations/cs/default.json +++ b/public/translations/cs/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "Zobrazit blikající červený indikátor, když položky čekají déle než tento čas", "no_content": "Žádný obsah", "view": "Zobrazit", - "excerpt": "Výňatek" + "excerpt": "Výňatek", + "publishing": "Publikování", + "approved": "Schváleno", + "rejected": "Zamítnuto" } diff --git a/public/translations/da/default.json b/public/translations/da/default.json index 3479f785..945407e6 100644 --- a/public/translations/da/default.json +++ b/public/translations/da/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "Vis en blinkende rød indikator, når elementer venter længere end denne tid", "no_content": "Intet indhold", "view": "Vis", - "excerpt": "Uddrag" + "excerpt": "Uddrag", + "publishing": "Udgivelse", + "approved": "Godkendt", + "rejected": "Afvist" } diff --git a/public/translations/de/default.json b/public/translations/de/default.json index 461f01fe..2d859e4c 100644 --- a/public/translations/de/default.json +++ b/public/translations/de/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "Einen blinkenden roten Indikator anzeigen, wenn Elemente länger als diese Zeit warten", "no_content": "Kein Inhalt", "view": "Anzeigen", - "excerpt": "Auszug" + "excerpt": "Auszug", + "publishing": "Veröffentlichung", + "approved": "Genehmigt", + "rejected": "Abgelehnt" } diff --git a/public/translations/el/default.json b/public/translations/el/default.json index 5a8fae48..8b19aae0 100644 --- a/public/translations/el/default.json +++ b/public/translations/el/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "Εμφάνιση αναβοσβήνοντος κόκκινου δείκτη όταν τα στοιχεία περιμένουν περισσότερο από αυτόν τον χρόνο", "no_content": "Χωρίς περιεχόμενο", "view": "Προβολή", - "excerpt": "Απόσπασμα" + "excerpt": "Απόσπασμα", + "publishing": "Δημοσίευση", + "approved": "Εγκεκριμένο", + "rejected": "Απορρίφθηκε" } diff --git a/public/translations/en/default.json b/public/translations/en/default.json index e514924d..cdca8677 100644 --- a/public/translations/en/default.json +++ b/public/translations/en/default.json @@ -265,5 +265,8 @@ "mod_queue_alert_threshold_tip": "Show a blinking red indicator when items are waiting for longer than this time", "no_content": "No content", "view": "View", - "excerpt": "Excerpt" + "excerpt": "Excerpt", + "publishing": "Publishing", + "approved": "Approved", + "rejected": "Rejected" } diff --git a/public/translations/es/default.json b/public/translations/es/default.json index a73b094e..edc2a26a 100644 --- a/public/translations/es/default.json +++ b/public/translations/es/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "Mostrar un indicador rojo parpadeante cuando los elementos están esperando más de este tiempo", "no_content": "Sin contenido", "view": "Ver", - "excerpt": "Extracto" + "excerpt": "Extracto", + "publishing": "Publicando", + "approved": "Aprobado", + "rejected": "Rechazado" } diff --git a/public/translations/fa/default.json b/public/translations/fa/default.json index 9006d62c..6e1f77ec 100644 --- a/public/translations/fa/default.json +++ b/public/translations/fa/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "نمایش نشانگر قرمز چشمک‌زن زمانی که موارد بیش از این زمان در انتظار هستند", "no_content": "بدون محتوا", "view": "مشاهده", - "excerpt": "گزیده" + "excerpt": "گزیده", + "publishing": "در حال انتشار", + "approved": "تایید شده", + "rejected": "رد شده" } diff --git a/public/translations/fi/default.json b/public/translations/fi/default.json index 6e80ea09..d7fcafe1 100644 --- a/public/translations/fi/default.json +++ b/public/translations/fi/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "Näytä vilkkuva punainen indikaattori, kun kohteet odottavat pidempään kuin tämä aika", "no_content": "Ei sisältöä", "view": "Näytä", - "excerpt": "Ote" + "excerpt": "Ote", + "publishing": "Julkaiseminen", + "approved": "Hyväksytty", + "rejected": "Hylätty" } diff --git a/public/translations/fil/default.json b/public/translations/fil/default.json index 6e0f6bce..e581593c 100644 --- a/public/translations/fil/default.json +++ b/public/translations/fil/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "Magpakita ng kumikislap na pulang indicator kapag ang mga item ay naghihintay nang mas mahaba kaysa sa oras na ito", "no_content": "Walang nilalaman", "view": "Tingnan", - "excerpt": "Sipi" + "excerpt": "Sipi", + "publishing": "Pag-publish", + "approved": "Naaprubado", + "rejected": "Tinanggihan" } diff --git a/public/translations/fr/default.json b/public/translations/fr/default.json index 09d17600..f33732de 100644 --- a/public/translations/fr/default.json +++ b/public/translations/fr/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "Afficher un indicateur rouge clignotant lorsque les éléments attendent plus longtemps que ce temps", "no_content": "Aucun contenu", "view": "Voir", - "excerpt": "Extrait" + "excerpt": "Extrait", + "publishing": "Publication", + "approved": "Approuvé", + "rejected": "Rejeté" } diff --git a/public/translations/he/default.json b/public/translations/he/default.json index be47e59e..47cc9019 100644 --- a/public/translations/he/default.json +++ b/public/translations/he/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "הצג אינדיקטור אדום מהבהב כאשר פריטים ממתינים יותר מזמן זה", "no_content": "אין תוכן", "view": "הצג", - "excerpt": "תקציר" + "excerpt": "תקציר", + "publishing": "מפרסם", + "approved": "אושר", + "rejected": "נדחה" } diff --git a/public/translations/hi/default.json b/public/translations/hi/default.json index edb657f6..b65da0c8 100644 --- a/public/translations/hi/default.json +++ b/public/translations/hi/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "जब आइटम इस समय से अधिक समय तक प्रतीक्षा कर रहे हों तो एक चमकता हुआ लाल संकेतक दिखाएं", "no_content": "कोई सामग्री नहीं", "view": "देखें", - "excerpt": "अंश" + "excerpt": "अंश", + "publishing": "प्रकाशन", + "approved": "अनुमोदित", + "rejected": "अस्वीकृत" } diff --git a/public/translations/hu/default.json b/public/translations/hu/default.json index b652ec2d..095370a2 100644 --- a/public/translations/hu/default.json +++ b/public/translations/hu/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "Villogó piros jelző megjelenítése, amikor az elemek ennél hosszabb ideig várakoznak", "no_content": "Nincs tartalom", "view": "Megtekintés", - "excerpt": "Kivonat" + "excerpt": "Kivonat", + "publishing": "Közzététel", + "approved": "Jóváhagyva", + "rejected": "Elutasítva" } diff --git a/public/translations/id/default.json b/public/translations/id/default.json index a440b3f4..cfbdd318 100644 --- a/public/translations/id/default.json +++ b/public/translations/id/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "Tampilkan indikator merah berkedip ketika item menunggu lebih lama dari waktu ini", "no_content": "Tidak ada konten", "view": "Lihat", - "excerpt": "Kutipan" + "excerpt": "Kutipan", + "publishing": "Menerbitkan", + "approved": "Disetujui", + "rejected": "Ditolak" } diff --git a/public/translations/it/default.json b/public/translations/it/default.json index b7ac1d11..3c17433a 100644 --- a/public/translations/it/default.json +++ b/public/translations/it/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "Mostra un indicatore rosso lampeggiante quando gli elementi attendono più di questo tempo", "no_content": "Nessun contenuto", "view": "Visualizza", - "excerpt": "Estratto" + "excerpt": "Estratto", + "publishing": "Pubblicazione", + "approved": "Approvato", + "rejected": "Rifiutato" } diff --git a/public/translations/ja/default.json b/public/translations/ja/default.json index 3c854b78..46eeb246 100644 --- a/public/translations/ja/default.json +++ b/public/translations/ja/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "アイテムがこの時間より長く待機している場合、点滅する赤いインジケーターを表示", "no_content": "コンテンツなし", "view": "表示", - "excerpt": "抜粋" + "excerpt": "抜粋", + "publishing": "公開中", + "approved": "承認済み", + "rejected": "却下" } diff --git a/public/translations/ko/default.json b/public/translations/ko/default.json index d38916c9..7ce2a231 100644 --- a/public/translations/ko/default.json +++ b/public/translations/ko/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "항목이 이 시간보다 오래 대기 중일 때 깜빡이는 빨간색 표시기 표시", "no_content": "콘텐츠 없음", "view": "보기", - "excerpt": "요약" + "excerpt": "요약", + "publishing": "게시 중", + "approved": "승인됨", + "rejected": "거부됨" } diff --git a/public/translations/mr/default.json b/public/translations/mr/default.json index 3c246ce5..6b7c50b4 100644 --- a/public/translations/mr/default.json +++ b/public/translations/mr/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "जेव्हा आयटम या वेळेपेक्षा जास्त वेळ प्रतीक्षा करत असतात तेव्हा एक चमकणारा लाल सूचक दाखवा", "no_content": "सामग्री नाही", "view": "पहा", - "excerpt": "उतारा" + "excerpt": "उतारा", + "publishing": "प्रकाशन करत आहे", + "approved": "मंजूर", + "rejected": "नाकारले" } diff --git a/public/translations/nl/default.json b/public/translations/nl/default.json index 24dd3e1d..12966192 100644 --- a/public/translations/nl/default.json +++ b/public/translations/nl/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "Toon een knipperende rode indicator wanneer items langer dan deze tijd wachten", "no_content": "Geen inhoud", "view": "Bekijken", - "excerpt": "Uittreksel" + "excerpt": "Uittreksel", + "publishing": "Publiceren", + "approved": "Goedgekeurd", + "rejected": "Afgewezen" } diff --git a/public/translations/no/default.json b/public/translations/no/default.json index 5d75f174..243e4a67 100644 --- a/public/translations/no/default.json +++ b/public/translations/no/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "Vis en blinkende rød indikator når elementer venter lenger enn denne tiden", "no_content": "Ingen innhold", "view": "Vis", - "excerpt": "Utdrag" + "excerpt": "Utdrag", + "publishing": "Publisering", + "approved": "Godkjent", + "rejected": "Avslått" } diff --git a/public/translations/pl/default.json b/public/translations/pl/default.json index 1a32dbae..fd21cf92 100644 --- a/public/translations/pl/default.json +++ b/public/translations/pl/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "Pokaż migający czerwony wskaźnik, gdy elementy czekają dłużej niż ten czas", "no_content": "Brak zawartości", "view": "Zobacz", - "excerpt": "Fragment" + "excerpt": "Fragment", + "publishing": "Publikowanie", + "approved": "Zatwierdzone", + "rejected": "Odrzucone" } diff --git a/public/translations/pt/default.json b/public/translations/pt/default.json index 382b2fd4..fd49c8cd 100644 --- a/public/translations/pt/default.json +++ b/public/translations/pt/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "Mostrar um indicador vermelho piscante quando os itens estão aguardando por mais tempo que este tempo", "no_content": "Sem conteúdo", "view": "Ver", - "excerpt": "Trecho" + "excerpt": "Trecho", + "publishing": "Publicando", + "approved": "Aprovado", + "rejected": "Rejeitado" } diff --git a/public/translations/ro/default.json b/public/translations/ro/default.json index fc6bd6df..5bd37255 100644 --- a/public/translations/ro/default.json +++ b/public/translations/ro/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "Afișează un indicator roșu intermitent când elementele așteaptă mai mult decât acest timp", "no_content": "Fără conținut", "view": "Vizualizează", - "excerpt": "Fragment" + "excerpt": "Fragment", + "publishing": "Publicare", + "approved": "Aprobat", + "rejected": "Respins" } diff --git a/public/translations/ru/default.json b/public/translations/ru/default.json index 49e4c0bd..031aa2a8 100644 --- a/public/translations/ru/default.json +++ b/public/translations/ru/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "Показывать мигающий красный индикатор, когда элементы ждут дольше этого времени", "no_content": "Нет содержимого", "view": "Просмотр", - "excerpt": "Выдержка" + "excerpt": "Выдержка", + "publishing": "Публикация", + "approved": "Одобрено", + "rejected": "Отклонено" } diff --git a/public/translations/sq/default.json b/public/translations/sq/default.json index bf2eb69d..9fd00101 100644 --- a/public/translations/sq/default.json +++ b/public/translations/sq/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "Shfaq një tregues të kuq që blinkon kur elementët po presin më shumë se kjo kohë", "no_content": "Pa përmbajtje", "view": "Shiko", - "excerpt": "Fragment" + "excerpt": "Fragment", + "publishing": "Publikimi", + "approved": "Aprovuar", + "rejected": "Refuzuar" } diff --git a/public/translations/sv/default.json b/public/translations/sv/default.json index af028034..85898235 100644 --- a/public/translations/sv/default.json +++ b/public/translations/sv/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "Visa en blinkande röd indikator när objekt väntar längre än denna tid", "no_content": "Inget innehåll", "view": "Visa", - "excerpt": "Utdrag" + "excerpt": "Utdrag", + "publishing": "Publicerar", + "approved": "Godkänd", + "rejected": "Avvisad" } diff --git a/public/translations/te/default.json b/public/translations/te/default.json index 09becb46..e62f80a5 100644 --- a/public/translations/te/default.json +++ b/public/translations/te/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "అంశాలు ఈ సమయం కంటే ఎక్కువ సమయం వేచి ఉన్నప్పుడు మెరిసే ఎరుపు సూచికను చూపించు", "no_content": "కంటెంట్ లేదు", "view": "చూడు", - "excerpt": "ఎక్సెర్ప్ట్" + "excerpt": "ఎక్సెర్ప్ట్", + "publishing": "ప్రచురించడం", + "approved": "అనుమోదించబడింది", + "rejected": "తిరస్కరించబడింది" } diff --git a/public/translations/th/default.json b/public/translations/th/default.json index 3886e88a..c6eb7882 100644 --- a/public/translations/th/default.json +++ b/public/translations/th/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "แสดงตัวบ่งชี้สีแดงกะพริบเมื่อรายการรอเกินเวลานี้", "no_content": "ไม่มีเนื้อหา", "view": "ดู", - "excerpt": "ข้อความย่อ" + "excerpt": "ข้อความย่อ", + "publishing": "กำลังเผยแพร่", + "approved": "อนุมัติแล้ว", + "rejected": "ปฏิเสธ" } diff --git a/public/translations/tr/default.json b/public/translations/tr/default.json index bea286f6..e889b202 100644 --- a/public/translations/tr/default.json +++ b/public/translations/tr/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "Öğeler bu süreden daha uzun süre beklediğinde yanıp sönen kırmızı bir gösterge göster", "no_content": "İçerik yok", "view": "Görüntüle", - "excerpt": "Alıntı" + "excerpt": "Alıntı", + "publishing": "Yayınlama", + "approved": "Onaylandı", + "rejected": "Reddedildi" } diff --git a/public/translations/uk/default.json b/public/translations/uk/default.json index 1930d1f2..91cb1023 100644 --- a/public/translations/uk/default.json +++ b/public/translations/uk/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "Показувати мигаючий червоний індикатор, коли елементи чекають довше цього часу", "no_content": "Немає вмісту", "view": "Перегляд", - "excerpt": "Витяг" + "excerpt": "Витяг", + "publishing": "Публікація", + "approved": "Схвалено", + "rejected": "Відхилено" } diff --git a/public/translations/ur/default.json b/public/translations/ur/default.json index e7d6cbb1..0234e35d 100644 --- a/public/translations/ur/default.json +++ b/public/translations/ur/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "جب آئٹمز اس وقت سے زیادہ انتظار کر رہے ہوں تو ایک ٹمٹمانے والا سرخ اشارہ دکھائیں", "no_content": "کوئی مواد نہیں", "view": "دیکھیں", - "excerpt": "اقتباس" + "excerpt": "اقتباس", + "publishing": "اشاعت", + "approved": "منظور شدہ", + "rejected": "مسترد" } diff --git a/public/translations/vi/default.json b/public/translations/vi/default.json index a451e8bd..c3262da1 100644 --- a/public/translations/vi/default.json +++ b/public/translations/vi/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "Hiển thị chỉ báo màu đỏ nhấp nháy khi các mục đang chờ lâu hơn thời gian này", "no_content": "Không có nội dung", "view": "Xem", - "excerpt": "Trích đoạn" + "excerpt": "Trích đoạn", + "publishing": "Đang xuất bản", + "approved": "Đã phê duyệt", + "rejected": "Đã từ chối" } diff --git a/public/translations/zh/default.json b/public/translations/zh/default.json index c53209f0..434572e8 100644 --- a/public/translations/zh/default.json +++ b/public/translations/zh/default.json @@ -266,5 +266,8 @@ "mod_queue_alert_threshold_tip": "当项目等待时间超过此时长时显示闪烁的红色指示器", "no_content": "无内容", "view": "查看", - "excerpt": "摘要" + "excerpt": "摘要", + "publishing": "发布中", + "approved": "已批准", + "rejected": "已拒绝" } diff --git a/src/views/mod-queue/mod-queue.tsx b/src/views/mod-queue/mod-queue.tsx index 1fa69393..75130482 100644 --- a/src/views/mod-queue/mod-queue.tsx +++ b/src/views/mod-queue/mod-queue.tsx @@ -14,6 +14,10 @@ import { useDefaultSubplebbits, MultisubSubplebbit } from '../../hooks/use-defau import { useBoardPath } from '../../hooks/use-resolved-subplebbit-address'; import { getHasThumbnail, getCommentMediaInfo } from '../../lib/utils/media-utils'; import useFeedResetStore from '../../stores/use-feed-reset-store'; +import useChallengesStore from '../../stores/use-challenges-store'; +import { alertChallengeVerificationFailed } from '../../lib/utils/challenge-utils'; + +const { addChallenge } = useChallengesStore.getState(); interface ModQueueViewProps { boardIdentifier?: string; // If provided, shows queue for single board @@ -38,10 +42,13 @@ interface ModQueueRowProps { showBoardColumn?: boolean; } +// Track which action was initiated to show appropriate completion message +type ModerationAction = 'approve' | 'reject' | null; + const ModQueueRow = ({ comment, showBoardColumn = false }: ModQueueRowProps) => { const { t } = useTranslation(); const { alertThresholdHours } = useModQueueStore(); - const [isModerating, setIsModerating] = useState(false); + const [initiatedAction, setInitiatedAction] = useState(null); const { content, title, timestamp, subplebbitAddress, cid, threadCid, link, thumbnailUrl, linkWidth, linkHeight } = comment; @@ -49,43 +56,109 @@ const ModQueueRow = ({ comment, showBoardColumn = false }: ModQueueRowProps) => const timeWaiting = Date.now() / 1000 - timestamp; const isOverThreshold = timeWaiting > alertThresholdHours * 3600; - const { publishCommentModeration: approve } = usePublishCommentModeration({ + const { + publishCommentModeration: approve, + state: approveState, + error: approveError, + } = usePublishCommentModeration({ commentCid: cid, subplebbitAddress, commentModeration: { approved: true }, + onChallenge: (...args: any) => addChallenge([...args, comment]), + onChallengeVerification: alertChallengeVerificationFailed, + onError: (error: Error) => { + console.error('Approve failed:', error); + }, }); - const { publishCommentModeration: reject } = usePublishCommentModeration({ + const { + publishCommentModeration: reject, + state: rejectState, + error: rejectError, + } = usePublishCommentModeration({ commentCid: cid, subplebbitAddress, commentModeration: { removed: true }, + onChallenge: (...args: any) => addChallenge([...args, comment]), + onChallengeVerification: alertChallengeVerificationFailed, + onError: (error: Error) => { + console.error('Reject failed:', error); + }, }); const handleApprove = async () => { + setInitiatedAction('approve'); try { - setIsModerating(true); await approve(); } catch (e) { console.error(e); - } finally { - setIsModerating(false); } }; const handleReject = async () => { + setInitiatedAction('reject'); try { - setIsModerating(true); await reject(); } catch (e) { console.error(e); - } finally { - setIsModerating(false); } }; + // Determine the current moderation state based on which action was initiated + const isApproving = initiatedAction === 'approve' && approveState !== 'initializing' && approveState !== 'succeeded' && approveState !== 'failed'; + const isRejecting = initiatedAction === 'reject' && rejectState !== 'initializing' && rejectState !== 'succeeded' && rejectState !== 'failed'; + const isPublishing = isApproving || isRejecting; + + const approveSucceeded = initiatedAction === 'approve' && approveState === 'succeeded'; + const rejectSucceeded = initiatedAction === 'reject' && rejectState === 'succeeded'; + + const approveFailed = initiatedAction === 'approve' && approveState === 'failed'; + const rejectFailed = initiatedAction === 'reject' && rejectState === 'failed'; + const excerpt = title || content || (getHasThumbnail(getCommentMediaInfo(link, thumbnailUrl, linkWidth, linkHeight), link) ? t('image') : t('no_content')); const postUrl = `/${boardPath}/thread/${threadCid || cid}`; + // Render the status or action buttons + const renderActions = () => { + if (approveSucceeded) { + return {t('approved')}; + } + if (rejectSucceeded) { + return {t('rejected')}; + } + if (approveFailed) { + return ( + + {t('failed')}: {approveError?.message} + + ); + } + if (rejectFailed) { + return ( + + {t('failed')}: {rejectError?.message} + + ); + } + if (isPublishing) { + return ; + } + + return ( + <> + + + + {t('view')} + + + ); + }; + return (
{showBoardColumn && ( @@ -99,17 +172,7 @@ const ModQueueRow = ({ comment, showBoardColumn = false }: ModQueueRowProps) =>
{formatDistanceToNow(timestamp * 1000, { addSuffix: false })}
-
- - - - {t('view')} - -
+
{renderActions()}
); };