Skip to content

Commit

Permalink
Update Dependencies (#7409)
Browse files Browse the repository at this point in the history
* dev dependencies

* update deps

* update wdb

* update more deps

* update detox deps

* update logs for database batch

* fix jest setup
  • Loading branch information
enahum authored Jun 21, 2023
1 parent bcc59d5 commit ef2c12e
Show file tree
Hide file tree
Showing 32 changed files with 5,710 additions and 5,883 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DatabaseHelper {
private fun setDefaultDatabase(context: Context) {
val databaseName = "app.db"
val databasePath = Uri.fromFile(context.filesDir).toString() + "/" + databaseName
defaultDatabase = Database(databasePath, context)
defaultDatabase = Database.getInstance(databasePath, context)
}

internal fun JSONObject.toMap(): Map<String, Any?> = keys().asSequence().associateWith { it ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fun DatabaseHelper.getDatabaseForServer(context: Context?, serverUrl: String): D
if (cursor.count == 1) {
cursor.moveToFirst()
val databasePath = cursor.getString(0)
return Database(databasePath, context!!)
return Database.getInstance(databasePath, context!!)
}
}
} catch (e: Exception) {
Expand Down
4 changes: 2 additions & 2 deletions app/database/operator/base_data_operator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ export default class BaseDataOperator {
try {
if (models.length > 0) {
await this.database.write(async (writer) => {
await writer.batch(models);
await writer.batch(...models);
}, description);
}
} catch (e) {
logWarning('batchRecords error ', e as Error);
logWarning('batchRecords error ', description, e as Error);
}
}

Expand Down
18 changes: 1 addition & 17 deletions app/managers/global_event_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@
// See LICENSE.txt for license information.

import {Alert, DeviceEventEmitter, Linking, NativeEventEmitter, NativeModules} from 'react-native';
import RNLocalize from 'react-native-localize';
import semver from 'semver';

import {switchToChannelById} from '@actions/remote/channel';
import {autoUpdateTimezone} from '@actions/remote/user';
import LocalConfig from '@assets/config.json';
import {Device, Events, Sso} from '@constants';
import {MIN_REQUIRED_VERSION} from '@constants/supported_server';
import DatabaseManager from '@database/manager';
import {DEFAULT_LOCALE, getTranslations, t} from '@i18n';
import {getServerCredentials} from '@init/credentials';
import * as analytics from '@managers/analytics';
import {getAllServers, getActiveServerUrl} from '@queries/app/servers';
import {getActiveServerUrl} from '@queries/app/servers';
import {queryTeamDefaultChannel} from '@queries/servers/channel';
import {getCommonSystemValues} from '@queries/servers/system';
import {getTeamChannelHistory} from '@queries/servers/team';
import {setScreensOrientation} from '@screens/navigation';
import {handleDeepLink} from '@utils/deep_link';
import {logError} from '@utils/log';

type LinkingCallbackArg = {url: string};

Expand All @@ -33,19 +30,6 @@ class GlobalEventHandler {
constructor() {
DeviceEventEmitter.addListener(Events.SERVER_VERSION_CHANGED, this.onServerVersionChanged);
DeviceEventEmitter.addListener(Events.CONFIG_CHANGED, this.onServerConfigChanged);
RNLocalize.addEventListener('change', async () => {
try {
const servers = await getAllServers();
for (const server of servers) {
if (server.url && server.lastActiveAt > 0) {
autoUpdateTimezone(server.url);
}
}
} catch (e) {
logError('Localize change', e);
}
});

splitViewEmitter.addListener('SplitViewChanged', this.onSplitViewChanged);
Linking.addEventListener('url', this.onDeepLink);
}
Expand Down
42 changes: 23 additions & 19 deletions app/screens/bottom_sheet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import BottomSheetM, {BottomSheetBackdrop, type BottomSheetBackdropProps, type BottomSheetFooterProps} from '@gorhom/bottom-sheet';
import React, {type ReactNode, useCallback, useEffect, useMemo, useRef} from 'react';
import {DeviceEventEmitter, type Handle, InteractionManager, Keyboard, type StyleProp, View, type ViewStyle} from 'react-native';
import {GestureHandlerRootView} from 'react-native-gesture-handler';

import {Events} from '@constants';
import {useTheme} from '@context/theme';
Expand Down Expand Up @@ -38,6 +39,7 @@ const PADDING_TOP_TABLET = 8;

export const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => {
return {
container: {flex: 1},
bottomSheet: {
backgroundColor: theme.centerChannelBg,
borderTopStartRadius: 24,
Expand Down Expand Up @@ -197,25 +199,27 @@ const BottomSheet = ({
}

return (
<BottomSheetM
ref={sheetRef}
index={initialSnapIndex}
snapPoints={snapPoints}
animateOnMount={true}
backdropComponent={renderBackdrop}
onAnimate={handleAnimationStart}
onChange={handleChange}
animationConfigs={animatedConfig}
handleComponent={Indicator}
style={styles.bottomSheet}
backgroundStyle={bottomSheetBackgroundStyle}
footerComponent={footerComponent}
keyboardBehavior='extend'
keyboardBlurBehavior='restore'
onClose={close}
>
{renderContainerContent()}
</BottomSheetM>
<GestureHandlerRootView style={styles.container}>
<BottomSheetM
ref={sheetRef}
index={initialSnapIndex}
snapPoints={snapPoints}
animateOnMount={true}
backdropComponent={renderBackdrop}
onAnimate={handleAnimationStart}
onChange={handleChange}
animationConfigs={animatedConfig}
handleComponent={Indicator}
style={styles.bottomSheet}
backgroundStyle={bottomSheetBackgroundStyle}
footerComponent={footerComponent}
keyboardBehavior='extend'
keyboardBlurBehavior='restore'
onClose={close}
>
{renderContainerContent()}
</BottomSheetM>
</GestureHandlerRootView>
);
};

Expand Down
2 changes: 1 addition & 1 deletion app/screens/custom_status_clear_after/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => {
class ClearAfterModal extends NavigationComponent<Props, State> {
private backListener: NativeEventSubscription | undefined;
constructor(props: Props) {
super(props);
super({...props, componentName: 'ClearAfterModal'});

const options: Options = {
topBar: {
Expand Down
1 change: 0 additions & 1 deletion app/screens/edit_profile/edit_profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ const EditProfile = ({
}

close();
return;
} catch (e) {
resetScreen(e);
}
Expand Down
24 changes: 24 additions & 0 deletions app/screens/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ import {DeviceEventEmitter, Platform} from 'react-native';
import HWKeyboardEvent from 'react-native-hw-keyboard-event';
import {enableFreeze, enableScreens} from 'react-native-screens';

import {autoUpdateTimezone} from '@actions/remote/user';
import ServerVersion from '@components/server_version';
import {Events, Screens} from '@constants';
import {useTheme} from '@context/theme';
import {useAppState} from '@hooks/device';
import {getAllServers} from '@queries/app/servers';
import {findChannels, popToRoot} from '@screens/navigation';
import NavigationStore from '@store/navigation_store';
import {handleDeepLink} from '@utils/deep_link';
import {logError} from '@utils/log';
import {alertChannelArchived, alertChannelRemove, alertTeamRemove} from '@utils/navigation';
import {notificationError} from '@utils/notification';

Expand All @@ -40,9 +44,23 @@ type HomeProps = LaunchProps & {

const Tab = createBottomTabNavigator();

const updateTimezoneIfNeeded = async () => {
try {
const servers = await getAllServers();
for (const server of servers) {
if (server.url && server.lastActiveAt > 0) {
autoUpdateTimezone(server.url);
}
}
} catch (e) {
logError('Localize change', e);
}
};

export default function HomeScreen(props: HomeProps) {
const theme = useTheme();
const intl = useIntl();
const appState = useAppState();

useEffect(() => {
const listener = DeviceEventEmitter.addListener(Events.NOTIFICATION_ERROR, (value: 'Team' | 'Channel' | 'Post' | 'Connection') => {
Expand Down Expand Up @@ -95,6 +113,12 @@ export default function HomeScreen(props: HomeProps) {
};
}, [intl.locale]);

useEffect(() => {
if (appState === 'active') {
updateTimezoneIfNeeded();
}
}, [appState]);

useEffect(() => {
if (props.launchType === 'deeplink') {
const deepLink = props.extra as DeepLinkWithData;
Expand Down
5 changes: 4 additions & 1 deletion app/screens/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ Navigation.setLazyComponentRegistrator((screenName) => {
break;
case Screens.BOTTOM_SHEET:
screen = withServerDatabase(require('@screens/bottom_sheet').default);
break;
Navigation.registerComponent(Screens.BOTTOM_SHEET, () =>
withSafeAreaInsets(withManagedConfig(screen)),
);
return;
case Screens.BROWSE_CHANNELS:
screen = withServerDatabase(require('@screens/browse_channels').default);
break;
Expand Down
1 change: 0 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module.exports = {
['@babel/plugin-proposal-decorators', {legacy: true}],
['@babel/plugin-transform-flow-strip-types'],
['@babel/plugin-proposal-class-properties', {loose: true}],
['@babel/plugin-proposal-private-property-in-object', {loose: true}],
['module-resolver', {
root: ['.'],
alias: {
Expand Down
Loading

0 comments on commit ef2c12e

Please sign in to comment.