refactor: remove unused isAdmin parameter in frontend socket

This commit is contained in:
antebrl
2025-05-03 19:09:16 +02:00
parent 170de2da33
commit f0ab4f70ba
5 changed files with 12 additions and 26 deletions

View File

@@ -345,8 +345,6 @@ function AppContent() {
selectedChannel={selectedChannel}
setSearchQuery={setSearchQuery}
onEditChannel={handleEditChannel}
isAdmin={isAdmin}
isAdminEnabled={isAdminEnabled}
/>
</div>
@@ -366,7 +364,6 @@ function AppContent() {
setEditChannel(null);
}}
channel={editChannel}
isAdmin={isAdmin}
/>
)}
@@ -383,7 +380,6 @@ function AppContent() {
<TvPlaylistModal
isOpen={isTvPlaylistOpen}
onClose={() => setIsTvPlaylistOpen(false)}
isAdmin={isAdmin}
/>
<AdminModal

View File

@@ -1,15 +1,12 @@
import React, { useState } from "react";
import React from "react";
import { Channel } from "../types";
import socketService from "../services/SocketService";
import { Lock } from "lucide-react";
interface ChannelListProps {
channels: Channel[];
selectedChannel: Channel | null;
setSearchQuery: React.Dispatch<React.SetStateAction<string>>;
onEditChannel: (channel: Channel) => void;
isAdmin?: boolean;
isAdminEnabled?: boolean;
}
function ChannelList({
@@ -17,8 +14,6 @@ function ChannelList({
selectedChannel,
setSearchQuery,
onEditChannel,
isAdmin = false,
isAdminEnabled = false,
}: ChannelListProps) {
const onSelectChannel = (channel: Channel) => {
setSearchQuery("");

View File

@@ -1,14 +1,15 @@
import { X, Copy, Tv2 } from 'lucide-react';
import { useContext } from 'react';
import { ToastContext } from './notifications/ToastContext';
import { useAdmin } from './admin/AdminContext';
interface TvPlaylistModalProps {
isOpen: boolean;
onClose: () => void;
isAdmin?: boolean;
}
function TvPlaylistModal({ isOpen, onClose, isAdmin = false }: TvPlaylistModalProps) {
function TvPlaylistModal({ isOpen, onClose }: TvPlaylistModalProps) {
const { isAdmin } = useAdmin();
const { addToast } = useContext(ToastContext);
const playlistUrl = `${import.meta.env.VITE_BACKEND_URL || window.location.origin}/api/channels/playlist`;

View File

@@ -9,10 +9,9 @@ import { ModeTooltipContent, Tooltip } from '../Tooltip';
interface ChannelModalProps {
onClose: () => void;
channel?: Channel | null;
isAdmin?: boolean;
}
function ChannelModal({ onClose, channel, isAdmin = false }: ChannelModalProps) {
function ChannelModal({ onClose, channel }: ChannelModalProps) {
const [type, setType] = useState<'channel' | 'playlist'>('playlist');
const [isEditMode, setIsEditMode] = useState(false);
const [inputMethod, setInputMethod] = useState<'url' | 'text'>('url');
@@ -102,7 +101,6 @@ function ChannelModal({ onClose, channel, isAdmin = false }: ChannelModalProps)
avatar.trim() || 'https://via.placeholder.com/64',
mode,
JSON.stringify(headers),
isAdmin
);
} else if (type === 'playlist') {
if (inputMethod === 'url' && !playlistUrl.trim()) return;
@@ -114,7 +112,6 @@ function ChannelModal({ onClose, channel, isAdmin = false }: ChannelModalProps)
mode,
playlistUpdate,
JSON.stringify(headers),
isAdmin
);
}
@@ -135,7 +132,7 @@ function ChannelModal({ onClose, channel, isAdmin = false }: ChannelModalProps)
avatar: avatar.trim() || 'https://via.placeholder.com/64',
mode: mode,
headers: headers,
}, isAdmin);
});
} else if (type === 'playlist') {
const newPlaylist = inputMethod === 'url' ? playlistUrl.trim() : playlistText.trim();
socketService.updatePlaylist(channel!.playlist, {
@@ -144,7 +141,7 @@ function ChannelModal({ onClose, channel, isAdmin = false }: ChannelModalProps)
playlistUpdate: playlistUpdate,
mode: mode,
headers: headers,
}, isAdmin);
});
}
addToast({
@@ -159,9 +156,9 @@ function ChannelModal({ onClose, channel, isAdmin = false }: ChannelModalProps)
const handleDelete = () => {
if (channel) {
if (type === 'channel') {
socketService.deleteChannel(channel.id, isAdmin);
socketService.deleteChannel(channel.id);
} else if (type === 'playlist') {
socketService.deletePlaylist(channel.playlist, isAdmin);
socketService.deletePlaylist(channel.playlist);
}
}
addToast({

View File

@@ -146,7 +146,6 @@ class SocketService {
avatar: string,
mode: ChannelMode,
headersJson: string,
isAdmin: boolean = false
) {
if (!this.socket || !this.socket.connected) {
this.connect();
@@ -173,7 +172,7 @@ class SocketService {
}
// Delete channel
deleteChannel(id: number, isAdmin: boolean = false) {
deleteChannel(id: number) {
if (!this.socket || !this.socket.connected) {
this.connect();
@@ -186,7 +185,7 @@ class SocketService {
}
// Update channel
updateChannel(id: number, updatedAttributes: any, isAdmin: boolean = false) {
updateChannel(id: number, updatedAttributes: any) {
if (!this.socket || !this.socket.connected) {
this.connect();
@@ -205,7 +204,6 @@ class SocketService {
mode: ChannelMode,
playlistUpdate: boolean,
headers: string,
isAdmin: boolean = false
) {
if (!this.socket || !this.socket.connected) {
this.connect();
@@ -228,7 +226,6 @@ class SocketService {
updatePlaylist(
playlist: string,
updatedAttributes: any,
isAdmin: boolean = false
) {
if (!this.socket || !this.socket.connected) {
this.connect();
@@ -242,7 +239,7 @@ class SocketService {
}
// Delete playlist
deletePlaylist(playlist: string, isAdmin: boolean = false) {
deletePlaylist(playlist: string) {
if (!this.socket || !this.socket.connected) {
this.connect();