2023-03-21 03:28:57 +08:00
|
|
|
import DarkReader from 'darkreader';
|
2024-07-03 01:58:58 +08:00
|
|
|
import Styled from './styles';
|
2023-03-21 03:28:57 +08:00
|
|
|
import logger from '/imports/startup/client/logger';
|
2024-06-13 04:44:52 +08:00
|
|
|
import useMeeting from '../../core/hooks/useMeeting';
|
2016-05-11 03:39:01 +08:00
|
|
|
|
2024-06-13 04:44:52 +08:00
|
|
|
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) => {
|
2023-03-21 03:28:57 +08:00
|
|
|
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(
|
|
|
|
{
|
2023-03-21 03:28:57 +08:00
|
|
|
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-03-21 03:28:57 +08:00
|
|
|
}
|
|
|
|
|
2023-07-25 02:56:40 +08:00
|
|
|
if (!value && DarkReader.isEnabled()) {
|
2023-03-21 03:28:57 +08:00
|
|
|
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-03-21 03:28:57 +08:00
|
|
|
}
|
2023-07-25 02:56:40 +08:00
|
|
|
};
|
2023-03-21 03:28:57 +08:00
|
|
|
|
2024-07-03 01:58:58 +08:00
|
|
|
export const isDarkThemeEnabled = () => DarkReader.isEnabled();
|
2023-03-21 03:28:57 +08:00
|
|
|
|
2023-07-25 02:56:40 +08:00
|
|
|
export default {
|
2023-03-21 03:28:57 +08:00
|
|
|
setDarkTheme,
|
|
|
|
isDarkThemeEnabled,
|
2024-06-13 04:44:52 +08:00
|
|
|
useMeetingIsBreakout,
|
2016-05-12 23:41:51 +08:00
|
|
|
};
|