bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/app/service.js

50 lines
1.0 KiB
JavaScript
Raw Normal View History

import DarkReader from 'darkreader';
2024-07-03 01:58:58 +08:00
import Styled from './styles';
import logger from '/imports/startup/client/logger';
import useMeeting from '../../core/hooks/useMeeting';
export function useMeetingIsBreakout() {
const { data: meeting } = useMeeting((m) => ({
isBreakout: m.isBreakout,
}));
return meeting && meeting.isBreakout;
}
2023-07-25 02:56:40 +08:00
export const setDarkTheme = (value) => {
if (value && !DarkReader.isEnabled()) {
2023-07-25 02:56:40 +08:00
DarkReader.enable(
{ brightness: 100, contrast: 90 },
{
invert: [Styled.DtfInvert],
ignoreInlineStyle: [Styled.DtfCss],
ignoreImageAnalysis: [Styled.DtfImages],
2024-07-03 01:58:58 +08:00
},
2023-07-25 02:56:40 +08:00
);
logger.info(
{
logCode: 'dark_mode',
2023-07-25 02:56:40 +08:00
},
2024-07-03 01:58:58 +08:00
'Dark mode is on.',
2023-07-25 02:56:40 +08:00
);
}
2023-07-25 02:56:40 +08:00
if (!value && DarkReader.isEnabled()) {
DarkReader.disable();
2023-07-25 02:56:40 +08:00
logger.info(
{
logCode: 'dark_mode',
},
2024-07-03 01:58:58 +08:00
'Dark mode is off.',
2023-07-25 02:56:40 +08:00
);
}
2023-07-25 02:56:40 +08:00
};
2024-07-03 01:58:58 +08:00
export const isDarkThemeEnabled = () => DarkReader.isEnabled();
2023-07-25 02:56:40 +08:00
export default {
setDarkTheme,
isDarkThemeEnabled,
useMeetingIsBreakout,
2016-05-12 23:41:51 +08:00
};