2024-08-10 01:58:44 +08:00
|
|
|
import * as 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';
|
2024-08-22 01:58:32 +08:00
|
|
|
import Storage from '/imports/ui/services/storage/session';
|
|
|
|
|
|
|
|
const CUSTOM_LOGO_URL_KEY = 'CustomLogoUrl';
|
|
|
|
|
|
|
|
const CUSTOM_DARK_LOGO_URL_KEY = 'CustomDarkLogoUrl';
|
|
|
|
|
|
|
|
const equalURLs = () => (
|
|
|
|
Storage.getItem(CUSTOM_LOGO_URL_KEY) === Storage.getItem(CUSTOM_DARK_LOGO_URL_KEY)
|
|
|
|
);
|
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) => {
|
2024-08-22 01:58:32 +08:00
|
|
|
let invert = [Styled.DtfInvert];
|
|
|
|
|
|
|
|
if(equalURLs()) {
|
|
|
|
invert = [Styled.DtfBrandingInvert];
|
|
|
|
}
|
|
|
|
|
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 },
|
|
|
|
{
|
2024-08-22 01:58:32 +08:00
|
|
|
invert,
|
2023-07-25 02:56:40 +08:00
|
|
|
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
|
|
|
};
|