|
@@ -9,7 +9,8 @@ import { UserPicture } from '@growi/ui';
|
|
|
import { withUnstatedContainers } from '../UnstatedUtils';
|
|
import { withUnstatedContainers } from '../UnstatedUtils';
|
|
|
import AppContainer from '~/client/services/AppContainer';
|
|
import AppContainer from '~/client/services/AppContainer';
|
|
|
import NavigationContainer from '~/client/services/NavigationContainer';
|
|
import NavigationContainer from '~/client/services/NavigationContainer';
|
|
|
-import { usePreferDrawerModeByUser } from '~/stores/ui';
|
|
|
|
|
|
|
+import { usePreferDrawerModeByUser, usePreferDrawerModeOnEditByUser } from '~/stores/ui';
|
|
|
|
|
+import { scheduleToPutUserUISettings } from '~/services/user-ui-settings';
|
|
|
|
|
|
|
|
import {
|
|
import {
|
|
|
isUserPreferenceExists,
|
|
isUserPreferenceExists,
|
|
@@ -29,13 +30,14 @@ import SunIcon from '../Icons/SunIcon';
|
|
|
|
|
|
|
|
const PersonalDropdown = (props) => {
|
|
const PersonalDropdown = (props) => {
|
|
|
|
|
|
|
|
- const { t, appContainer, navigationContainer } = props;
|
|
|
|
|
|
|
+ const { t, appContainer } = props;
|
|
|
const user = appContainer.currentUser || {};
|
|
const user = appContainer.currentUser || {};
|
|
|
|
|
|
|
|
const [useOsSettings, setOsSettings] = useState(!isUserPreferenceExists());
|
|
const [useOsSettings, setOsSettings] = useState(!isUserPreferenceExists());
|
|
|
const [isDarkMode, setIsDarkMode] = useState(isDarkModeByUtil());
|
|
const [isDarkMode, setIsDarkMode] = useState(isDarkModeByUtil());
|
|
|
|
|
|
|
|
const { data: isPreferDrawerMode, mutate: mutatePreferDrawerMode } = usePreferDrawerModeByUser();
|
|
const { data: isPreferDrawerMode, mutate: mutatePreferDrawerMode } = usePreferDrawerModeByUser();
|
|
|
|
|
+ const { data: isPreferDrawerModeOnEdit, mutate: mutatePreferDrawerModeOnEdit } = usePreferDrawerModeOnEditByUser();
|
|
|
|
|
|
|
|
const logoutHandler = () => {
|
|
const logoutHandler = () => {
|
|
|
const { interceptorManager } = appContainer;
|
|
const { interceptorManager } = appContainer;
|
|
@@ -51,11 +53,13 @@ const PersonalDropdown = (props) => {
|
|
|
|
|
|
|
|
const preferDrawerModeSwitchModifiedHandler = useCallback((bool) => {
|
|
const preferDrawerModeSwitchModifiedHandler = useCallback((bool) => {
|
|
|
mutatePreferDrawerMode(bool);
|
|
mutatePreferDrawerMode(bool);
|
|
|
|
|
+ scheduleToPutUserUISettings({ preferDrawerModeByUser: bool });
|
|
|
}, [mutatePreferDrawerMode]);
|
|
}, [mutatePreferDrawerMode]);
|
|
|
|
|
|
|
|
- const preferDrawerModeOnEditSwitchModifiedHandler = (bool) => {
|
|
|
|
|
- navigationContainer.setDrawerModePreferenceOnEdit(bool);
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ const preferDrawerModeOnEditSwitchModifiedHandler = useCallback((bool) => {
|
|
|
|
|
+ mutatePreferDrawerModeOnEdit(bool);
|
|
|
|
|
+ scheduleToPutUserUISettings({ preferDrawerModeOnEditByUser: bool });
|
|
|
|
|
+ }, [mutatePreferDrawerModeOnEdit]);
|
|
|
|
|
|
|
|
const followOsCheckboxModifiedHandler = (bool) => {
|
|
const followOsCheckboxModifiedHandler = (bool) => {
|
|
|
if (bool) {
|
|
if (bool) {
|
|
@@ -80,13 +84,6 @@ const PersonalDropdown = (props) => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
- /*
|
|
|
|
|
- * render
|
|
|
|
|
- */
|
|
|
|
|
- const {
|
|
|
|
|
- preferDrawerModeByUser, preferDrawerModeOnEditByUser,
|
|
|
|
|
- } = navigationContainer.state;
|
|
|
|
|
-
|
|
|
|
|
/* eslint-disable react/prop-types */
|
|
/* eslint-disable react/prop-types */
|
|
|
const IconWithTooltip = ({
|
|
const IconWithTooltip = ({
|
|
|
id, label, children, additionalClasses,
|
|
id, label, children, additionalClasses,
|
|
@@ -172,7 +169,7 @@ const PersonalDropdown = (props) => {
|
|
|
id="swSidebarModeOnEditor"
|
|
id="swSidebarModeOnEditor"
|
|
|
className="custom-control-input"
|
|
className="custom-control-input"
|
|
|
type="checkbox"
|
|
type="checkbox"
|
|
|
- checked={!preferDrawerModeOnEditByUser}
|
|
|
|
|
|
|
+ checked={!isPreferDrawerModeOnEdit}
|
|
|
onChange={e => preferDrawerModeOnEditSwitchModifiedHandler(!e.target.checked)}
|
|
onChange={e => preferDrawerModeOnEditSwitchModifiedHandler(!e.target.checked)}
|
|
|
/>
|
|
/>
|
|
|
<label className="custom-control-label" htmlFor="swSidebarModeOnEditor"></label>
|
|
<label className="custom-control-label" htmlFor="swSidebarModeOnEditor"></label>
|
|
@@ -239,13 +236,12 @@ const PersonalDropdown = (props) => {
|
|
|
/**
|
|
/**
|
|
|
* Wrapper component for using unstated
|
|
* Wrapper component for using unstated
|
|
|
*/
|
|
*/
|
|
|
-const PersonalDropdownWrapper = withUnstatedContainers(PersonalDropdown, [AppContainer, NavigationContainer]);
|
|
|
|
|
|
|
+const PersonalDropdownWrapper = withUnstatedContainers(PersonalDropdown, [AppContainer]);
|
|
|
|
|
|
|
|
|
|
|
|
|
PersonalDropdown.propTypes = {
|
|
PersonalDropdown.propTypes = {
|
|
|
t: PropTypes.func.isRequired, // i18next
|
|
t: PropTypes.func.isRequired, // i18next
|
|
|
appContainer: PropTypes.instanceOf(AppContainer).isRequired,
|
|
appContainer: PropTypes.instanceOf(AppContainer).isRequired,
|
|
|
- navigationContainer: PropTypes.instanceOf(NavigationContainer).isRequired,
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
export default withTranslation()(PersonalDropdownWrapper);
|
|
export default withTranslation()(PersonalDropdownWrapper);
|