add tray and add settings
This commit is contained in:
@ -42,6 +42,8 @@ export default function CoinsDisplay({
|
||||
|
||||
sx,
|
||||
}: CoinsDisplayProps) {
|
||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||
const [settingsVersion, setSettingsVersion] = useState(0);
|
||||
const storageKey = useMemo(() => {
|
||||
// ключ под конкретного пользователя
|
||||
return username ? `coins:${username}` : 'coins:anonymous';
|
||||
@ -71,7 +73,24 @@ export default function CoinsDisplay({
|
||||
return 0;
|
||||
});
|
||||
|
||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||
useEffect(() => {
|
||||
const handler = () => setSettingsVersion((v) => v + 1);
|
||||
window.addEventListener('settings-updated', handler as EventListener);
|
||||
return () => window.removeEventListener('settings-updated', handler as EventListener);
|
||||
}, []);
|
||||
|
||||
const isTooltipDisabledBySettings = useMemo(() => {
|
||||
try {
|
||||
const raw = localStorage.getItem('launcher_settings');
|
||||
if (!raw) return false;
|
||||
const s = JSON.parse(raw);
|
||||
return Boolean(s?.disableToolTip);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}, [settingsVersion]);
|
||||
|
||||
const tooltipEnabled = showTooltip && !isTooltipDisabledBySettings;
|
||||
|
||||
const getSizes = () => {
|
||||
switch (size) {
|
||||
@ -172,7 +191,7 @@ export default function CoinsDisplay({
|
||||
borderRadius: sizes.borderRadius,
|
||||
padding: sizes.containerPadding,
|
||||
border: '1px solid rgba(255, 255, 255, 0.1)',
|
||||
cursor: showTooltip ? 'help' : 'default',
|
||||
cursor: tooltipEnabled ? 'help' : 'default',
|
||||
|
||||
// можно оставить лёгкий намёк на загрузку, но без "пульса" текста
|
||||
opacity: isLoading ? 0.85 : 1,
|
||||
@ -222,7 +241,7 @@ export default function CoinsDisplay({
|
||||
</Box>
|
||||
);
|
||||
|
||||
if (showTooltip) {
|
||||
if (tooltipEnabled) {
|
||||
return (
|
||||
<CustomTooltip
|
||||
title={tooltipText}
|
||||
|
||||
Reference in New Issue
Block a user