refactor: Admin-Status direkt aus Redux ausgelesen und Props entfernt
- isAdminLoggedIn wird jetzt direkt aus authSlice im Redux-Store gelesen - useAdminAuth und Prop-Weitergabe entfernt - Flackern des Firmware-Buttons dauerhaft behoben - Codestruktur vereinfacht und stabilisiert
This commit is contained in:
@@ -13,7 +13,6 @@ import ConfirmModal from "@/components/common/ConfirmModal";
|
||||
interface Props {
|
||||
slot: number;
|
||||
showModal: boolean;
|
||||
isAdminLoggedIn: boolean; // NEU
|
||||
onClose?: () => void;
|
||||
onModulNameChange?: (id: string) => void;
|
||||
}
|
||||
@@ -32,7 +31,6 @@ const memoryIntervalOptions = [
|
||||
|
||||
export default function KueEinstellung({
|
||||
slot,
|
||||
isAdminLoggedIn,
|
||||
onClose = () => {},
|
||||
onModulNameChange,
|
||||
}: Props) {
|
||||
@@ -46,6 +44,11 @@ export default function KueEinstellung({
|
||||
kueLoopInterval,
|
||||
memoryInterval,
|
||||
} = useSelector((state: RootState) => state.kueDataSlice);
|
||||
const reduxAdmin = useSelector(
|
||||
(state: RootState) => state.authSlice.isAdminLoggedIn
|
||||
);
|
||||
const [isAdminLoggedIn] = useState(() => reduxAdmin);
|
||||
|
||||
const [showConfirmModal, setShowConfirmModal] = useState(false);
|
||||
|
||||
const [isUpdating, setIsUpdating] = useState(false);
|
||||
|
||||
@@ -21,7 +21,8 @@ declare global {
|
||||
}
|
||||
|
||||
export default function KueModal({ showModal, onClose, slot }: KueModalProps) {
|
||||
const { isAdminLoggedIn } = useAdminAuth(true);
|
||||
const { isAdminLoggedIn: reduxIsAdminLoggedIn } = useAdminAuth(true);
|
||||
const [isAdminLoggedIn] = useState(() => reduxIsAdminLoggedIn); // stabil, flackerfrei
|
||||
|
||||
const [activeTab, setActiveTab] = useState<"kue" | "tdr" | "knoten">(() => {
|
||||
if (typeof window !== "undefined" && window.__lastKueTab) {
|
||||
@@ -41,7 +42,9 @@ export default function KueModal({ showModal, onClose, slot }: KueModalProps) {
|
||||
window.kabelModalOpen = showModal;
|
||||
}
|
||||
}, [showModal]);
|
||||
//-----------------------------------------------------
|
||||
|
||||
//------------------------------------------------------
|
||||
return (
|
||||
<ReactModal
|
||||
isOpen={showModal}
|
||||
|
||||
Reference in New Issue
Block a user