Skip to content

Commit

Permalink
feat(mark-all-button): add countdown to auto-confirm message (#1414)
Browse files Browse the repository at this point in the history
  • Loading branch information
moeyua authored Nov 5, 2024
1 parent 51a4bd2 commit e1a5fc6
Show file tree
Hide file tree
Showing 21 changed files with 34 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { RootPortal } from "@follow/components/ui/portal/index.jsx"
import { cn, getOS } from "@follow/utils/utils"
import { AnimatePresence, m } from "framer-motion"
import type { FC, ReactNode } from "react"
import { forwardRef, Fragment, useState } from "react"
import { forwardRef, Fragment, useEffect, useState } from "react"
import { useHotkeys } from "react-hotkeys-hook"
import { Trans, useTranslation } from "react-i18next"
import { toast } from "sonner"
Expand Down Expand Up @@ -186,14 +186,26 @@ const Popup = ({ which, containerRef, setPopoverRef, setShow, handleMarkAllAsRea

const ConfirmMarkAllReadInfo = ({ undo }: { undo: () => any }) => {
const { t } = useTranslation()
const [countdown, setCountdown] = useState(3)

useHotkeys("ctrl+z,meta+z", undo, {
scopes: HotKeyScopeMap.Home,
preventDefault: true,
})

useEffect(() => {
if (countdown > 0) {
const timer = setTimeout(() => setCountdown(countdown - 1), 1000)
return () => clearTimeout(timer)
}
}, [countdown])

return (
<div>
<p>{t("mark_all_read_button.confirm_mark_all_info")}</p>
<small className="opacity-50">{t("mark_all_read_button.auto_confirm_info")}</small>
<small className="opacity-50">
{t("mark_all_read_button.auto_confirm_info", { countdown })}
</small>
</div>
)
}
Expand Down
2 changes: 1 addition & 1 deletion locales/app/ar-DZ.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"feed_view_type.pictures": "صور",
"feed_view_type.social_media": "وسائل التواصل الاجتماعي",
"feed_view_type.videos": "فيديوهات",
"mark_all_read_button.auto_confirm_info": "سيتم التأكيد تلقائيًا بعد 3 ثوانٍ.",
"mark_all_read_button.auto_confirm_info": "سيتم التأكيد تلقائيًا بعد {{countdown}} ثوانٍ.",
"mark_all_read_button.confirm": "تأكيد",
"mark_all_read_button.confirm_mark_all": "هل تريد تحديد <which /> كمقروء؟",
"mark_all_read_button.confirm_mark_all_info": "تأكيد تحديد الكل كمقروء؟",
Expand Down
2 changes: 1 addition & 1 deletion locales/app/ar-IQ.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"feed_view_type.pictures": "صور",
"feed_view_type.social_media": "وسائل التواصل الاجتماعي",
"feed_view_type.videos": "فيديوهات",
"mark_all_read_button.auto_confirm_info": "سيتم التأكيد تلقائيًا بعد 3 ثوانٍ.",
"mark_all_read_button.auto_confirm_info": "سيتم التأكيد تلقائيًا بعد {{countdown}} ثوانٍ.",
"mark_all_read_button.confirm": "تأكيد",
"mark_all_read_button.confirm_mark_all": "تحديد <which /> كمقروء؟",
"mark_all_read_button.confirm_mark_all_info": "تأكيد تحديد الكل كمقروء؟",
Expand Down
2 changes: 1 addition & 1 deletion locales/app/ar-KW.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"feed_view_type.pictures": "صور",
"feed_view_type.social_media": "وسائل التواصل الاجتماعي",
"feed_view_type.videos": "فيديوهات",
"mark_all_read_button.auto_confirm_info": "سيتم التأكيد تلقائيًا بعد 3 ثوانٍ.",
"mark_all_read_button.auto_confirm_info": "سيتم التأكيد تلقائيًا بعد {{countdown}} ثوانٍ.",
"mark_all_read_button.confirm": "تأكيد",
"mark_all_read_button.confirm_mark_all": "وضع علامة <which /> كمقروء؟",
"mark_all_read_button.confirm_mark_all_info": "تأكيد وضع علامة الجميع كمقروء؟",
Expand Down
2 changes: 1 addition & 1 deletion locales/app/ar-MA.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"feed_view_type.pictures": "صور",
"feed_view_type.social_media": "وسائل التواصل الاجتماعي",
"feed_view_type.videos": "فيديوهات",
"mark_all_read_button.auto_confirm_info": "سيتم التأكيد تلقائيًا بعد 3 ثوانٍ.",
"mark_all_read_button.auto_confirm_info": "سيتم التأكيد تلقائيًا بعد {{countdown}} ثوانٍ.",
"mark_all_read_button.confirm": "تأكيد",
"mark_all_read_button.confirm_mark_all": "وضع علامة على <which /> كمقروء؟",
"mark_all_read_button.confirm_mark_all_info": "تأكيد وضع علامة على الكل كمقروء؟",
Expand Down
2 changes: 1 addition & 1 deletion locales/app/ar-SA.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"feed_view_type.pictures": "صور",
"feed_view_type.social_media": "وسائل التواصل الاجتماعي",
"feed_view_type.videos": "فيديوهات",
"mark_all_read_button.auto_confirm_info": "سيتم التأكيد تلقائيًا بعد 3 ثوانٍ.",
"mark_all_read_button.auto_confirm_info": "سيتم التأكيد تلقائيًا بعد {{countdown}} ثوانٍ.",
"mark_all_read_button.confirm": "تأكيد",
"mark_all_read_button.confirm_mark_all": "تمييز <which /> كمقروء؟",
"mark_all_read_button.confirm_mark_all_info": "هل ترغب في تأكيد تمييز الكل كمقروء؟",
Expand Down
2 changes: 1 addition & 1 deletion locales/app/ar-TN.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"feed_view_type.pictures": "صور",
"feed_view_type.social_media": "وسائل التواصل الاجتماعي",
"feed_view_type.videos": "مقاطع فيديو",
"mark_all_read_button.auto_confirm_info": "سيتم التأكيد تلقائيًا بعد 3 ثوانٍ.",
"mark_all_read_button.auto_confirm_info": "سيتم التأكيد تلقائيًا بعد {{countdown}} ثوانٍ.",
"mark_all_read_button.confirm": "تأكيد",
"mark_all_read_button.confirm_mark_all": "وضع علامة <which /> كمقروء؟",
"mark_all_read_button.confirm_mark_all_info": "تأكيد وضع الجميع كمقروء؟",
Expand Down
2 changes: 1 addition & 1 deletion locales/app/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"feed_view_type.pictures": "Bilder",
"feed_view_type.social_media": "Soziale Medien",
"feed_view_type.videos": "Videos",
"mark_all_read_button.auto_confirm_info": "Wird nach 3 Sekunden automatisch bestätigt.",
"mark_all_read_button.auto_confirm_info": "Wird nach {{countdown}} Sekunden automatisch bestätigt.",
"mark_all_read_button.confirm": "Bestätigen",
"mark_all_read_button.confirm_mark_all": "<which /> als gelesen markieren?",
"mark_all_read_button.confirm_mark_all_info": "Möchten Sie alle als gelesen markieren?",
Expand Down
2 changes: 1 addition & 1 deletion locales/app/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
"feed_view_type.pictures": "Pictures",
"feed_view_type.social_media": "Social Media",
"feed_view_type.videos": "Videos",
"mark_all_read_button.auto_confirm_info": "Will be confirmed automatically after 3s.",
"mark_all_read_button.auto_confirm_info": "Will be confirmed automatically after {{countdown}}s.",
"mark_all_read_button.confirm": "Confirm",
"mark_all_read_button.confirm_mark_all": "Mark <which /> as read?",
"mark_all_read_button.confirm_mark_all_info": "Confirm mark all as read?",
Expand Down
2 changes: 1 addition & 1 deletion locales/app/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"feed_view_type.pictures": "Imágenes",
"feed_view_type.social_media": "Redes Sociales",
"feed_view_type.videos": "Videos",
"mark_all_read_button.auto_confirm_info": "Confirmación automática después de 3 segundos.",
"mark_all_read_button.auto_confirm_info": "Confirmación automática después de {{countdown}} segundos.",
"mark_all_read_button.confirm": "Confirmar",
"mark_all_read_button.confirm_mark_all": "¿Marcar <which /> como leído?",
"mark_all_read_button.confirm_mark_all_info": "¿Confirmar marcar todo como leído?",
Expand Down
2 changes: 1 addition & 1 deletion locales/app/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"feed_view_type.pictures": "Kuvat",
"feed_view_type.social_media": "Sosiaalinen media",
"feed_view_type.videos": "Videot",
"mark_all_read_button.auto_confirm_info": "Vahvistetaan automaattisesti 3 sekunnin kuluttua.",
"mark_all_read_button.auto_confirm_info": "Vahvistetaan automaattisesti {{countdown}} sekunnin kuluttua.",
"mark_all_read_button.confirm": "Vahvista",
"mark_all_read_button.confirm_mark_all": "Merkitäänkö <which /> luetuksi?",
"mark_all_read_button.confirm_mark_all_info": "Vahvista kaikki merkinnät luetuiksi?",
Expand Down
2 changes: 1 addition & 1 deletion locales/app/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"feed_view_type.pictures": "Images",
"feed_view_type.social_media": "Réseaux sociaux",
"feed_view_type.videos": "Vidéos",
"mark_all_read_button.auto_confirm_info": "Sera confirmé automatiquement après 3s.",
"mark_all_read_button.auto_confirm_info": "Sera confirmé automatiquement après {{countdown}}s.",
"mark_all_read_button.confirm": "Confirmer",
"mark_all_read_button.confirm_mark_all": "Marquer <which /> comme lu ?",
"mark_all_read_button.confirm_mark_all_info": "Confirmez que vous voulez tout marquer comme lu ?",
Expand Down
2 changes: 1 addition & 1 deletion locales/app/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"feed_view_type.pictures": "Immagini",
"feed_view_type.social_media": "Social Media",
"feed_view_type.videos": "Video",
"mark_all_read_button.auto_confirm_info": "Sarà confermato automaticamente dopo 3s.",
"mark_all_read_button.auto_confirm_info": "Sarà confermato automaticamente dopo {{countdown}}s.",
"mark_all_read_button.confirm": "Conferma",
"mark_all_read_button.confirm_mark_all": "Segna <which /> come letto?",
"mark_all_read_button.confirm_mark_all_info": "Confermi di segnare tutto come letto?",
Expand Down
2 changes: 1 addition & 1 deletion locales/app/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
"feed_view_type.pictures": "画像",
"feed_view_type.social_media": "ソーシャルメディア",
"feed_view_type.videos": "動画",
"mark_all_read_button.auto_confirm_info": "3 秒後に自動的に確認されます。",
"mark_all_read_button.auto_confirm_info": "{{countdown}} 秒後に自動的に確認されます。",
"mark_all_read_button.confirm": "確認",
"mark_all_read_button.confirm_mark_all": "<which />を既読にしますか?",
"mark_all_read_button.confirm_mark_all_info": "すべてを既読にしますか?",
Expand Down
2 changes: 1 addition & 1 deletion locales/app/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"feed_view_type.pictures": "사진",
"feed_view_type.social_media": "소셜 미디어",
"feed_view_type.videos": "비디오",
"mark_all_read_button.auto_confirm_info": "3 초 후 자동으로 확인됩니다.",
"mark_all_read_button.auto_confirm_info": "{{countdown}} 초 후 자동으로 확인됩니다.",
"mark_all_read_button.confirm": "확인",
"mark_all_read_button.confirm_mark_all": "<which />을 (를) 모두 읽음으로 표시하시겠습니까?",
"mark_all_read_button.confirm_mark_all_info": "모두 읽음으로 표시하시겠습니까?",
Expand Down
2 changes: 1 addition & 1 deletion locales/app/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"feed_view_type.pictures": "画像",
"feed_view_type.social_media": "ソーシャルメディア",
"feed_view_type.videos": "動画",
"mark_all_read_button.auto_confirm_info": "3 秒後に自動的に確認されます。",
"mark_all_read_button.auto_confirm_info": "{{countdown}} 秒後に自動的に確認されます。",
"mark_all_read_button.confirm": "確認",
"mark_all_read_button.confirm_mark_all": "<which />を既読にしますか?",
"mark_all_read_button.confirm_mark_all_info": "すべてを既読にしますか?",
Expand Down
2 changes: 1 addition & 1 deletion locales/app/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"feed_view_type.pictures": "Картинки",
"feed_view_type.social_media": "Социальные сети",
"feed_view_type.videos": "Видео",
"mark_all_read_button.auto_confirm_info": "Будет автоматически подтверждено через 3 секунды.",
"mark_all_read_button.auto_confirm_info": "Будет автоматически подтверждено через {{countdown}} секунды.",
"mark_all_read_button.confirm": "Подтвердить",
"mark_all_read_button.confirm_mark_all": "Отметить <which /> как прочитанное?",
"mark_all_read_button.confirm_mark_all_info": "Подтвердить отметку всего как прочитанное?",
Expand Down
2 changes: 1 addition & 1 deletion locales/app/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"feed_view_type.pictures": "Resimler",
"feed_view_type.social_media": "Sosyal Medya",
"feed_view_type.videos": "Videolar",
"mark_all_read_button.auto_confirm_info": "3 saniye sonra otomatik olarak onaylanacak.",
"mark_all_read_button.auto_confirm_info": "{{countdown}} saniye sonra otomatik olarak onaylanacak.",
"mark_all_read_button.confirm": "Onayla",
"mark_all_read_button.confirm_mark_all": "<which /> okundu olarak işaretlensin mi?",
"mark_all_read_button.confirm_mark_all_info": "Tümünü okundu olarak işaretlemeyi onaylıyor musunuz?",
Expand Down
2 changes: 1 addition & 1 deletion locales/app/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
"feed_view_type.pictures": "图片",
"feed_view_type.social_media": "社交媒体",
"feed_view_type.videos": "视频",
"mark_all_read_button.auto_confirm_info": "3 秒后自动确认",
"mark_all_read_button.auto_confirm_info": "{{countdown}} 秒后自动确认",
"mark_all_read_button.confirm": "确认",
"mark_all_read_button.confirm_mark_all": "将 <which /> 标记为已读?",
"mark_all_read_button.confirm_mark_all_info": "确认将全部标记为已读?",
Expand Down
2 changes: 1 addition & 1 deletion locales/app/zh-HK.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
"feed_view_type.pictures": "圖片",
"feed_view_type.social_media": "社交媒體",
"feed_view_type.videos": "影片",
"mark_all_read_button.auto_confirm_info": "將在 3 秒後自動確認",
"mark_all_read_button.auto_confirm_info": "將在 {{countdown}} 秒後自動確認",
"mark_all_read_button.confirm": "確認",
"mark_all_read_button.confirm_mark_all": "確定將 <which /> 標記為已讀?",
"mark_all_read_button.confirm_mark_all_info": "確定將所有標記為已讀?",
Expand Down
2 changes: 1 addition & 1 deletion locales/app/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
"feed_view_type.pictures": "圖片",
"feed_view_type.social_media": "社交媒體",
"feed_view_type.videos": "影片",
"mark_all_read_button.auto_confirm_info": "將在 3 秒後自動確認。",
"mark_all_read_button.auto_confirm_info": "將在 {{countdown}} 秒後自動確認。",
"mark_all_read_button.confirm": "確認",
"mark_all_read_button.confirm_mark_all": "將 <which /> 標記為已讀?",
"mark_all_read_button.confirm_mark_all_info": "確認將全部標記為已讀?",
Expand Down

0 comments on commit e1a5fc6

Please sign in to comment.