b7348cffdd
This is a workaround to the conflict that is happening when an user tries to download the slide when dark mode is enabled. There is a conflict between dark mode's styles and the html-to-image lib. To temporarily prevent this from happening, the dark mode is disabled before downloading the slide, and then re-enabled when the download is complete. In order to be able to enable and disable dark mode from another component than the App, all the dark mode switch logic was extracted into the service of the app component.
63 lines
1.6 KiB
JavaScript
63 lines
1.6 KiB
JavaScript
import Breakouts from '/imports/api/breakouts';
|
|
import Meetings from '/imports/api/meetings';
|
|
import Settings from '/imports/ui/services/settings';
|
|
import Auth from '/imports/ui/services/auth/index';
|
|
import deviceInfo from '/imports/utils/deviceInfo';
|
|
import Styled from './styles';
|
|
import DarkReader from 'darkreader';
|
|
import logger from '/imports/startup/client/logger';
|
|
|
|
const getFontSize = () => {
|
|
const applicationSettings = Settings.application;
|
|
return applicationSettings ? applicationSettings.fontSize : '16px';
|
|
};
|
|
|
|
const getBreakoutRooms = () => Breakouts.find().fetch();
|
|
|
|
function meetingIsBreakout() {
|
|
const meeting = Meetings.findOne({ meetingId: Auth.meetingID },
|
|
{ fields: { 'meetingProp.isBreakout': 1 } });
|
|
return (meeting && meeting.meetingProp.isBreakout);
|
|
}
|
|
|
|
const validIOSVersion = () => {
|
|
const { isIos, isIosVersionSupported } = deviceInfo;
|
|
|
|
if (isIos) {
|
|
return isIosVersionSupported();
|
|
}
|
|
return true;
|
|
};
|
|
|
|
const setDarkTheme = (value) => {
|
|
if (value && !DarkReader.isEnabled()) {
|
|
DarkReader.enable(
|
|
{ brightness: 100, contrast: 90 },
|
|
{ invert: [Styled.DtfInvert], ignoreInlineStyle: [Styled.DtfCss], ignoreImageAnalysis: [Styled.DtfImages] },
|
|
)
|
|
logger.info({
|
|
logCode: 'dark_mode',
|
|
}, 'Dark mode is on.');
|
|
}
|
|
|
|
if (!value && DarkReader.isEnabled()){
|
|
DarkReader.disable();
|
|
logger.info({
|
|
logCode: 'dark_mode',
|
|
}, 'Dark mode is off.');
|
|
}
|
|
}
|
|
|
|
const isDarkThemeEnabled = () => {
|
|
return DarkReader.isEnabled()
|
|
}
|
|
|
|
export {
|
|
getFontSize,
|
|
meetingIsBreakout,
|
|
getBreakoutRooms,
|
|
validIOSVersion,
|
|
setDarkTheme,
|
|
isDarkThemeEnabled,
|
|
};
|