fix Require cycle
This commit is contained in:
parent
8901afb0d8
commit
3650cdfc6d
12 changed files with 53 additions and 44 deletions
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {postActionWithCookie} from '@actions/remote/post';
|
||||
import {ActionType, Post} from '@constants';
|
||||
import DatabaseManager from '@database/manager';
|
||||
import {getPostById, prepareDeletePost} from '@queries/servers/post';
|
||||
|
|
@ -133,10 +132,6 @@ export const removePost = async (serverUrl: string, post: PostModel | Post) => {
|
|||
return {post};
|
||||
};
|
||||
|
||||
export const selectAttachmentMenuAction = (serverUrl: string, postId: string, actionId: string, selectedOption: string) => {
|
||||
return postActionWithCookie(serverUrl, postId, actionId, '', selectedOption);
|
||||
};
|
||||
|
||||
export const markPostAsDeleted = async (serverUrl: string, post: Post) => {
|
||||
const operator = DatabaseManager.serverDatabases[serverUrl]?.operator;
|
||||
if (!operator) {
|
||||
|
|
|
|||
|
|
@ -3,10 +3,6 @@
|
|||
|
||||
import {getTimeZone} from 'react-native-localize';
|
||||
|
||||
import {updateMe} from '@actions/remote/user';
|
||||
import DatabaseManager from '@database/manager';
|
||||
import {getUserById} from '@queries/servers/user';
|
||||
|
||||
import type UserModel from '@typings/database/models/servers/user';
|
||||
|
||||
export const isTimezoneEnabled = (config: Partial<ClientConfig>) => {
|
||||
|
|
@ -17,28 +13,6 @@ export function getDeviceTimezone() {
|
|||
return getTimeZone();
|
||||
}
|
||||
|
||||
export const autoUpdateTimezone = async (serverUrl: string, {deviceTimezone, userId}: {deviceTimezone: string; userId: string}) => {
|
||||
const database = DatabaseManager.serverDatabases[serverUrl].database;
|
||||
if (!database) {
|
||||
return {error: `No database present for ${serverUrl}`};
|
||||
}
|
||||
|
||||
const currentUser = await getUserById(database, userId);
|
||||
|
||||
if (!currentUser) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const currentTimezone = getUserTimezone(currentUser);
|
||||
const newTimezoneExists = currentTimezone.automaticTimezone !== deviceTimezone;
|
||||
|
||||
if (currentTimezone.useAutomaticTimezone && newTimezoneExists) {
|
||||
const timezone = {useAutomaticTimezone: 'true', automaticTimezone: deviceTimezone, manualTimezone: currentTimezone.manualTimezone};
|
||||
await updateMe(serverUrl, {timezone});
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
export const getUserTimezone = (currentUser: UserModel) => {
|
||||
if (currentUser?.timezone) {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -854,3 +854,7 @@ export async function fetchSavedPosts(serverUrl: string, teamId?: string, channe
|
|||
return {error};
|
||||
}
|
||||
}
|
||||
|
||||
export const selectAttachmentMenuAction = (serverUrl: string, postId: string, actionId: string, selectedOption: string) => {
|
||||
return postActionWithCookie(serverUrl, postId, actionId, '', selectedOption);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import {DeviceEventEmitter} from 'react-native';
|
||||
|
||||
import {autoUpdateTimezone, getDeviceTimezone, isTimezoneEnabled} from '@actions/local/timezone';
|
||||
import {getDeviceTimezone, isTimezoneEnabled} from '@actions/local/timezone';
|
||||
import {Database, Events} from '@constants';
|
||||
import {SYSTEM_IDENTIFIERS} from '@constants/database';
|
||||
import DatabaseManager from '@database/manager';
|
||||
|
|
@ -17,6 +17,7 @@ import {getCSRFFromCookie} from '@utils/security';
|
|||
import {loginEntry} from './entry';
|
||||
import {logError} from './error';
|
||||
import {fetchDataRetentionPolicy} from './systems';
|
||||
import {autoUpdateTimezone} from './user';
|
||||
|
||||
import type ClientError from '@client/rest/error';
|
||||
import type {LoginArgs} from '@typings/database/database';
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
/* eslint-disable max-lines */
|
||||
|
||||
import {Model} from '@nozbe/watermelondb';
|
||||
import {chunk} from 'lodash';
|
||||
|
||||
import {updateChannelsDisplayName} from '@actions/local/channel';
|
||||
import {getUserTimezone} from '@actions/local/timezone';
|
||||
import {updateRecentCustomStatuses, updateLocalUser} from '@actions/local/user';
|
||||
import {fetchRolesIfNeeded} from '@actions/remote/role';
|
||||
import {General} from '@constants';
|
||||
|
|
@ -13,7 +16,7 @@ import {debounce} from '@helpers/api/general';
|
|||
import NetworkManager from '@init/network_manager';
|
||||
import {queryChannelsByTypes} from '@queries/servers/channel';
|
||||
import {getCurrentTeamId, getCurrentUserId} from '@queries/servers/system';
|
||||
import {getCurrentUser, prepareUsers, queryAllUsers, queryUsersById, queryUsersByUsername} from '@queries/servers/user';
|
||||
import {getCurrentUser, getUserById, prepareUsers, queryAllUsers, queryUsersById, queryUsersByUsername} from '@queries/servers/user';
|
||||
import {removeUserFromList} from '@utils/user';
|
||||
|
||||
import {forceLogoutIfNecessary} from './session';
|
||||
|
|
@ -693,3 +696,25 @@ export const buildProfileImageUrl = (serverUrl: string, userId: string, timestam
|
|||
|
||||
return client.getProfilePictureUrl(userId, timestamp);
|
||||
};
|
||||
|
||||
export const autoUpdateTimezone = async (serverUrl: string, {deviceTimezone, userId}: {deviceTimezone: string; userId: string}) => {
|
||||
const database = DatabaseManager.serverDatabases[serverUrl].database;
|
||||
if (!database) {
|
||||
return {error: `No database present for ${serverUrl}`};
|
||||
}
|
||||
|
||||
const currentUser = await getUserById(database, userId);
|
||||
|
||||
if (!currentUser) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const currentTimezone = getUserTimezone(currentUser);
|
||||
const newTimezoneExists = currentTimezone.automaticTimezone !== deviceTimezone;
|
||||
|
||||
if (currentTimezone.useAutomaticTimezone && newTimezoneExists) {
|
||||
const timezone = {useAutomaticTimezone: 'true', automaticTimezone: deviceTimezone, manualTimezone: currentTimezone.manualTimezone};
|
||||
await updateMe(serverUrl, {timezone});
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import React, {useCallback, useState} from 'react';
|
||||
|
||||
import {selectAttachmentMenuAction} from '@actions/local/post';
|
||||
import {selectAttachmentMenuAction} from '@actions/remote/post';
|
||||
import AutocompleteSelector from '@components/autocomplete_selector';
|
||||
import {useServerUrl} from '@context/server';
|
||||
|
||||
|
|
|
|||
|
|
@ -22,8 +22,9 @@ import {withServerUrl} from '@context/server';
|
|||
import {withTheme} from '@context/theme';
|
||||
import {observeConfig, observeRecentCustomStatus} from '@queries/servers/system';
|
||||
import {observeCurrentUser} from '@queries/servers/user';
|
||||
import {dismissModal, goToScreen, mergeNavigationOptions, showModal} from '@screens/navigation';
|
||||
import {dismissModal, goToScreen, showModal} from '@screens/navigation';
|
||||
import {getCurrentMomentForTimezone, getRoundedTime, isCustomStatusExpirySupported} from '@utils/helpers';
|
||||
import {mergeNavigationOptions} from '@utils/navigation';
|
||||
import {preventDoubleTap} from '@utils/tap';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme';
|
||||
import {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ import {
|
|||
|
||||
import {CustomStatusDuration} from '@constants/custom_status';
|
||||
import {observeCurrentUser} from '@queries/servers/user';
|
||||
import {dismissModal, mergeNavigationOptions, popTopScreen} from '@screens/navigation';
|
||||
import {dismissModal, popTopScreen} from '@screens/navigation';
|
||||
import {mergeNavigationOptions} from '@utils/navigation';
|
||||
import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme';
|
||||
|
||||
import ClearAfterMenuItem from './components/clear_after_menu_item';
|
||||
|
|
|
|||
|
|
@ -14,12 +14,13 @@ import NavigationConstants from '@constants/navigation';
|
|||
import {getDefaultThemeByAppearance} from '@context/theme';
|
||||
import EphemeralStore from '@store/ephemeral_store';
|
||||
import {LaunchProps, LaunchType} from '@typings/launch';
|
||||
import {NavButtons} from '@typings/screens/navigation';
|
||||
import {appearanceControlledScreens, mergeNavigationOptions} from '@utils/navigation';
|
||||
import {changeOpacity, setNavigatorStyles} from '@utils/theme';
|
||||
|
||||
import type {NavButtons} from '@typings/screens/navigation';
|
||||
|
||||
const {MattermostManaged} = NativeModules;
|
||||
const isRunningInSplitView = MattermostManaged.isRunningInSplitView;
|
||||
export const appearanceControlledScreens = [Screens.SERVER, Screens.LOGIN, Screens.FORGOT_PASSWORD, Screens.MFA, Screens.SSO];
|
||||
|
||||
const alpha = {
|
||||
from: 0,
|
||||
|
|
@ -592,10 +593,6 @@ export function setButtons(componentId: string, buttons: NavButtons = {leftButto
|
|||
mergeNavigationOptions(componentId, options);
|
||||
}
|
||||
|
||||
export function mergeNavigationOptions(componentId: string, options: Options) {
|
||||
Navigation.mergeOptions(componentId, options);
|
||||
}
|
||||
|
||||
export function showOverlay(name: string, passProps = {}, options = {}) {
|
||||
if (!isScreenRegistered(name)) {
|
||||
return;
|
||||
|
|
|
|||
12
app/utils/navigation/index.ts
Normal file
12
app/utils/navigation/index.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {Navigation, Options} from 'react-native-navigation';
|
||||
|
||||
import {Screens} from '@constants';
|
||||
|
||||
export const appearanceControlledScreens = [Screens.SERVER, Screens.LOGIN, Screens.FORGOT_PASSWORD, Screens.MFA, Screens.SSO];
|
||||
|
||||
export function mergeNavigationOptions(componentId: string, options: Options) {
|
||||
Navigation.mergeOptions(componentId, options);
|
||||
}
|
||||
|
|
@ -7,8 +7,8 @@ import tinyColor from 'tinycolor2';
|
|||
|
||||
import {Preferences} from '@constants';
|
||||
import {MODAL_SCREENS_WITHOUT_BACK} from '@constants/screens';
|
||||
import {appearanceControlledScreens, mergeNavigationOptions} from '@screens/navigation';
|
||||
import EphemeralStore from '@store/ephemeral_store';
|
||||
import {appearanceControlledScreens, mergeNavigationOptions} from '@utils/navigation';
|
||||
|
||||
import type {Options} from 'react-native-navigation';
|
||||
|
||||
|
|
|
|||
1
index.ts
1
index.ts
|
|
@ -25,7 +25,6 @@ if (__DEV__) {
|
|||
LogBox.ignoreLogs([
|
||||
'`-[RCTRootView cancelTouches]`',
|
||||
'scaleY',
|
||||
'Require cycle: node_modules/zod/lib/src/index.js',
|
||||
"[react-native-gesture-handler] Seems like you're using an old API with gesture components, check out new Gestures system!",
|
||||
'new NativeEventEmitter',
|
||||
]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue