diff --git a/src/components/blocking/ChannelSubscriptionScreen.tsx b/src/components/blocking/ChannelSubscriptionScreen.tsx index d6d45ce..88a2cfe 100644 --- a/src/components/blocking/ChannelSubscriptionScreen.tsx +++ b/src/components/blocking/ChannelSubscriptionScreen.tsx @@ -43,7 +43,8 @@ export default function ChannelSubscriptionScreen() { return () => clearInterval(timer); }, [cooldown]); - const channels = channelInfo?.channels ?? []; + const allChannels = channelInfo?.channels ?? []; + const channels = allChannels.filter((ch) => !ch.is_subscribed); const checkSubscription = useCallback(async () => { if (isCheckingRef.current) return; @@ -88,35 +89,23 @@ export default function ChannelSubscriptionScreen() { {channelInfo?.message || t('blocking.channel.defaultMessage')}

- {/* Channel list */} + {/* Channel list (only unsubscribed channels) */} {channels.length > 0 && (
{channels.map((ch) => (
{ch.title || ch.channel_id} -
- {ch.is_subscribed ? ( - - {t('blocking.channel.subscribed')} - - ) : ( - ch.channel_link && ( - - ) - )} -
+ {ch.channel_link && ( + + )}
))}
diff --git a/src/locales/en.json b/src/locales/en.json index faba9c4..2b6ffcd 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1308,16 +1308,19 @@ "disabled": "Disabled", "enable": "Enable", "disable": "Disable", + "edit": "Edit", + "editing": "Editing", "delete": "Delete", "deleteConfirm": "Delete this channel?", "sortOrder": "Order", "form": { "title": "Display Name", "channelId": "Channel ID", - "channelIdHint": "@username or -100XXXXXXXXXX", + "channelIdHint": "-100XXXXXXXXXX", "channelLink": "Channel Link", "channelLinkHint": "https://t.me/channel", "submit": "Add", + "save": "Save", "cancel": "Cancel" } }, diff --git a/src/locales/fa.json b/src/locales/fa.json index 993618d..61e7267 100644 --- a/src/locales/fa.json +++ b/src/locales/fa.json @@ -1011,16 +1011,19 @@ "disabled": "غیرفعال", "enable": "فعال‌سازی", "disable": "غیرفعال‌سازی", + "edit": "ویرایش", + "editing": "ویرایش", "delete": "حذف", "deleteConfirm": "این کانال حذف شود؟", "sortOrder": "ترتیب", "form": { "title": "نام نمایشی", "channelId": "شناسه کانال", - "channelIdHint": "@username یا -100XXXXXXXXXX", + "channelIdHint": "-100XXXXXXXXXX", "channelLink": "لینک کانال", "channelLinkHint": "https://t.me/channel", "submit": "افزودن", + "save": "ذخیره", "cancel": "لغو" } }, diff --git a/src/locales/ru.json b/src/locales/ru.json index fe0a6ed..e10b230 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -1334,16 +1334,19 @@ "disabled": "Отключён", "enable": "Включить", "disable": "Отключить", + "edit": "Изменить", + "editing": "Редактирование", "delete": "Удалить", "deleteConfirm": "Удалить этот канал?", "sortOrder": "Порядок", "form": { "title": "Название", "channelId": "ID канала", - "channelIdHint": "@username или -100XXXXXXXXXX", + "channelIdHint": "-100XXXXXXXXXX", "channelLink": "Ссылка на канал", "channelLinkHint": "https://t.me/channel", "submit": "Добавить", + "save": "Сохранить", "cancel": "Отмена" } }, diff --git a/src/locales/zh.json b/src/locales/zh.json index 4041148..b493a0d 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -1063,16 +1063,19 @@ "disabled": "已禁用", "enable": "启用", "disable": "禁用", + "edit": "编辑", + "editing": "编辑", "delete": "删除", "deleteConfirm": "删除此频道?", "sortOrder": "排序", "form": { "title": "显示名称", "channelId": "频道ID", - "channelIdHint": "@username 或 -100XXXXXXXXXX", + "channelIdHint": "-100XXXXXXXXXX", "channelLink": "频道链接", "channelLinkHint": "https://t.me/channel", "submit": "添加", + "save": "保存", "cancel": "取消" } }, diff --git a/src/pages/AdminChannelSubscriptions.tsx b/src/pages/AdminChannelSubscriptions.tsx index fcef8e0..ba37fca 100644 --- a/src/pages/AdminChannelSubscriptions.tsx +++ b/src/pages/AdminChannelSubscriptions.tsx @@ -6,6 +6,7 @@ import { adminChannelsApi, type RequiredChannel, type CreateChannelRequest, + type UpdateChannelRequest, } from '../api/adminChannels'; import { AdminBackButton } from '../components/admin'; @@ -58,6 +59,16 @@ const XIcon = () => ( ); +const EditIcon = () => ( + + + +); + const LinkIcon = () => ( void; onDelete: (id: number) => void; + onEdit: (channel: RequiredChannel) => void; }) { const { t } = useTranslation(); @@ -137,6 +150,14 @@ function ChannelCard({ {/* Action buttons */}
+ + {channel.is_active ? ( + +
+ + + ); +} + // Main component export default function AdminChannelSubscriptions() { const { t } = useTranslation(); @@ -268,6 +422,7 @@ export default function AdminChannelSubscriptions() { const haptic = useHaptic(); const notify = useNotify(); const [showAddForm, setShowAddForm] = useState(false); + const [editingChannel, setEditingChannel] = useState(null); // Fetch channels const { data, isLoading, refetch } = useQuery({ @@ -312,6 +467,20 @@ export default function AdminChannelSubscriptions() { }, }); + const updateMutation = useMutation({ + mutationFn: ({ id, data }: { id: number; data: UpdateChannelRequest }) => + adminChannelsApi.update(id, data), + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ['admin-channels'] }); + setEditingChannel(null); + haptic.impact('light'); + }, + onError: () => { + haptic.notification('error'); + notify.error(t('common.error')); + }, + }); + const handleToggle = (id: number) => { toggleMutation.mutate(id); }; @@ -326,6 +495,15 @@ export default function AdminChannelSubscriptions() { createMutation.mutate(data); }; + const handleUpdate = (id: number, data: UpdateChannelRequest) => { + updateMutation.mutate({ id, data }); + }; + + const handleEdit = (channel: RequiredChannel) => { + setEditingChannel(channel); + setShowAddForm(false); + }; + const channels = data?.items ?? []; return ( @@ -354,7 +532,7 @@ export default function AdminChannelSubscriptions() { > - {!showAddForm && ( + {!showAddForm && !editingChannel && (