[Gekidou] update dependencies (#6019)

* Dependency updates

* npm audit fixes
This commit is contained in:
Elias Nahum
2022-03-01 18:52:01 -03:00
committed by GitHub
parent 5de54471b7
commit eaf4f3166e
28 changed files with 2276 additions and 3393 deletions

View File

@@ -3,9 +3,8 @@
import {Platform} from 'react-native';
import {switchToChannel} from '@actions/local/channel';
import {updatePostSinceCache} from '@actions/local/notification';
import {fetchMissingSidebarInfo, fetchMyChannel, markChannelAsRead} from '@actions/remote/channel';
import {fetchMissingSidebarInfo, fetchMyChannel, markChannelAsRead, switchToChannelById} from '@actions/remote/channel';
import {forceLogoutIfNecessary} from '@actions/remote/session';
import {fetchMyTeam} from '@actions/remote/team';
import {Preferences} from '@constants';
@@ -13,13 +12,11 @@ import DatabaseManager from '@database/manager';
import {getTeammateNameDisplaySetting} from '@helpers/api/preference';
import {queryChannelsById, queryMyChannel} from '@queries/servers/channel';
import {queryPreferencesByCategoryAndName} from '@queries/servers/preference';
import {queryCommonSystemValues} from '@queries/servers/system';
import {queryCommonSystemValues, queryWebSocketLastDisconnected} from '@queries/servers/system';
import {queryMyTeamById} from '@queries/servers/team';
import {queryCurrentUser} from '@queries/servers/user';
import {emitNotificationError} from '@utils/notification';
import {fetchPostsForChannel} from './post';
const fetchNotificationData = async (serverUrl: string, notification: NotificationWithData, skipEvents = false) => {
const operator = DatabaseManager.serverDatabases[serverUrl]?.operator;
if (!operator) {
@@ -81,7 +78,6 @@ const fetchNotificationData = async (serverUrl: string, notification: Notificati
}
}
fetchPostsForChannel(serverUrl, channelId);
return {};
} catch (error) {
forceLogoutIfNecessary(serverUrl, error as ClientErrorProps);
@@ -90,11 +86,20 @@ const fetchNotificationData = async (serverUrl: string, notification: Notificati
};
export const backgroundNotification = async (serverUrl: string, notification: NotificationWithData) => {
if (Platform.OS === 'ios') {
updatePostSinceCache(serverUrl, notification);
const database = DatabaseManager.serverDatabases[serverUrl]?.database;
if (!database) {
return;
}
await fetchNotificationData(serverUrl, notification, true);
const lastDisconnectedAt = await queryWebSocketLastDisconnected(database);
if (lastDisconnectedAt) {
if (Platform.OS === 'ios') {
updatePostSinceCache(serverUrl, notification);
}
await fetchNotificationData(serverUrl, notification, true);
}
};
export const openNotification = async (serverUrl: string, notification: NotificationWithData) => {
@@ -126,8 +131,7 @@ export const openNotification = async (serverUrl: string, notification: Notifica
const myTeam = await queryMyTeamById(database, teamId);
if (myChannel && myTeam) {
fetchPostsForChannel(serverUrl, channelId);
switchToChannel(serverUrl, channelId, teamId);
switchToChannelById(serverUrl, channelId, teamId);
return {};
}
@@ -136,7 +140,7 @@ export const openNotification = async (serverUrl: string, notification: Notifica
return {error: result.error};
}
return switchToChannel(serverUrl, channelId, teamId);
return switchToChannelById(serverUrl, channelId, teamId);
} catch (error) {
forceLogoutIfNecessary(serverUrl, error as ClientErrorProps);
return {error};

View File

@@ -116,6 +116,7 @@ export async function handleNewPostEvent(serverUrl: string, msg: WebSocketMessag
//const viewingGlobalThreads = getViewingGlobalThreads(state);
// const collapsedThreadsEnabled = isCollapsedThreadsEnabled(state);
// actions.push(receivedNewPost(post, collapsedThreadsEnabled));
if (!shouldIgnorePost(post)) {
let markAsViewed = false;
let markAsRead = false;
@@ -153,6 +154,7 @@ export async function handleNewPostEvent(serverUrl: string, msg: WebSocketMessag
myChannel.messageCount + 1,
myChannel.mentionsCount + (hasMentions ? 1 : 0),
myChannel.lastViewedAt,
true,
);
if (unreadAt) {
models.push(unreadAt);

View File

@@ -36,6 +36,9 @@ export const transformChannelRecord = ({action, database, value}: TransformerArg
channel.createAt = raw.create_at;
channel.creatorId = raw.creator_id;
channel.deleteAt = raw.delete_at;
// for DM channels do not override the display name
// until we get the new info if there is any
channel.displayName = raw.display_name || record?.displayName || '';
channel.isGroupConstrained = Boolean(raw.group_constrained);
channel.name = raw.name;

View File

@@ -168,6 +168,8 @@ export function useGalleryControls() {
const translateYConfig: WithTimingConfig = {
duration: 400,
// @ts-expect-error EasingFactoryFunction missing in type definition
easing: Easing.bezier(0.33, 0.01, 0, 1),
};

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Database, Model, Q, Query, Relation} from '@nozbe/watermelondb';
import {Database, Model, Q, Query} from '@nozbe/watermelondb';
import {Database as DatabaseConstants, Preferences} from '@constants';
import {getPreferenceValue} from '@helpers/api/preference';
@@ -193,11 +193,17 @@ export const deleteMyTeams = async (operator: ServerDataOperator, teams: TeamMod
try {
const preparedModels: Model[] = [];
for await (const team of teams) {
const myTeam = await team.myTeam.fetch() as MyTeamModel;
preparedModels.push(myTeam.prepareDestroyPermanently());
try {
const myTeam = await team.myTeam.fetch() as MyTeamModel;
preparedModels.push(myTeam.prepareDestroyPermanently());
} catch {
// Record not found, do nothing
}
}
await operator.batchRecords(preparedModels);
if (preparedModels.length) {
await operator.batchRecords(preparedModels);
}
return {};
} catch (error) {
return {error};
@@ -205,37 +211,55 @@ export const deleteMyTeams = async (operator: ServerDataOperator, teams: TeamMod
};
export const prepareDeleteTeam = async (team: TeamModel): Promise<Model[]> => {
const preparedModels: Model[] = [team.prepareDestroyPermanently()];
try {
const preparedModels: Model[] = [team.prepareDestroyPermanently()];
const relations: Array<Relation<Model>> = [team.myTeam, team.teamChannelHistory];
for await (const relation of relations) {
try {
const model = await relation.fetch();
const model = await team.myTeam.fetch();
if (model) {
preparedModels.push(model.prepareDestroyPermanently());
}
} catch {
// Record not found, do nothing
}
}
const associatedChildren: Array<Query<any>> = [
team.members,
team.slashCommands,
team.teamSearchHistories,
];
for await (const children of associatedChildren) {
const models = await children.fetch() as Model[];
models.forEach((model) => preparedModels.push(model.prepareDestroyPermanently()));
}
try {
const model = await team.teamChannelHistory.fetch();
if (model) {
preparedModels.push(model.prepareDestroyPermanently());
}
} catch {
// Record not found, do nothing
}
const channels = await team.channels.fetch() as ChannelModel[];
for await (const channel of channels) {
const preparedChannel = await prepareDeleteChannel(channel);
preparedModels.push(...preparedChannel);
}
const associatedChildren: Array<Query<any>> = [
team.members,
team.slashCommands,
team.teamSearchHistories,
];
for await (const children of associatedChildren) {
try {
const models = await children.fetch() as Model[];
models.forEach((model) => preparedModels.push(model.prepareDestroyPermanently()));
} catch {
// Record not found, do nothing
}
}
return preparedModels;
const channels = await team.channels.fetch() as ChannelModel[];
for await (const channel of channels) {
try {
const preparedChannel = await prepareDeleteChannel(channel);
preparedModels.push(...preparedChannel);
} catch {
// Record not found, do nothing
}
}
return preparedModels;
} catch (error) {
return [];
}
};
export const queryMyTeamById = async (database: Database, teamId: string): Promise<MyTeamModel|undefined> => {

View File

@@ -2,8 +2,8 @@
// See LICENSE.txt for license information.
import React, {useCallback, useEffect, useState} from 'react';
import {DeviceEventEmitter, StyleSheet, View, ViewStyle} from 'react-native';
import Animated, {AnimatedStyleProp} from 'react-native-reanimated';
import {DeviceEventEmitter, StyleProp, StyleSheet, View, ViewStyle} from 'react-native';
import Animated from 'react-native-reanimated';
import {SafeAreaView, Edge} from 'react-native-safe-area-context';
import {Events} from '@constants';
@@ -33,7 +33,7 @@ type Props = {
isDirectChannel: boolean;
item: GalleryItemType;
post?: PostModel;
style: AnimatedStyleProp<ViewStyle>;
style: StyleProp<ViewStyle>;
teammateNameDisplay: string;
}

View File

@@ -146,7 +146,7 @@ const Gallery = forwardRef<GalleryRef, GalleryProps>(({
return (
<AnimatedImage
source={{uri: item.posterUri}}
style={info.itemStyles as StyleProp<Animated.AnimateStyle<StyleProp<ImageStyle>>>}
style={info.itemStyles as StyleProp<ImageStyle>}
/>
);
}

View File

@@ -2,9 +2,9 @@
// See LICENSE.txt for license information.
import React, {useMemo} from 'react';
import {StyleSheet, useWindowDimensions, View, ViewStyle} from 'react-native';
import {StyleProp, StyleSheet, useWindowDimensions, View, ViewStyle} from 'react-native';
import {TouchableOpacity} from 'react-native-gesture-handler';
import Animated, {AnimatedStyleProp} from 'react-native-reanimated';
import Animated from 'react-native-reanimated';
import {SafeAreaView, Edge} from 'react-native-safe-area-context';
import CompassIcon from '@components/compass_icon';
@@ -16,7 +16,7 @@ import {typography} from '@utils/typography';
type Props = {
index: number;
onClose: () => void;
style: AnimatedStyleProp<ViewStyle>;
style: StyleProp<ViewStyle>;
total: number;
}

View File

@@ -42,6 +42,8 @@ const springConfig: WithSpringConfig = {
const timingConfig: WithTimingConfig = {
duration: 250,
// @ts-expect-error EasingFactoryFunction missing in type definition
easing: Easing.bezier(0.33, 0.01, 0, 1),
};

View File

@@ -58,6 +58,8 @@ const AnimatedImage = Animated.createAnimatedComponent(FastImage);
const timingConfig: WithTimingConfig = {
duration: 250,
// @ts-expect-error EasingFactoryFunction missing in type definition
easing: Easing.bezier(0.5002, 0.2902, 0.3214, 0.9962),
};

View File

@@ -22,6 +22,8 @@ interface VideoRendererProps extends ImageRendererProps {
const AnimatedVideo = Animated.createAnimatedComponent(Video);
const timingConfig: WithTimingConfig = {
duration: 250,
// @ts-expect-error EasingFactoryFunction missing in type definition
easing: Easing.bezier(0.33, 0.01, 0, 1),
};

View File

@@ -3,7 +3,7 @@
import React, {useEffect, useRef, useState} from 'react';
import {DeviceEventEmitter, Platform, StyleSheet, Text, TouchableOpacity, View} from 'react-native';
import {GestureDetector, Gesture} from 'react-native-gesture-handler';
import {GestureDetector, Gesture, GestureHandlerRootView} from 'react-native-gesture-handler';
import {Navigation} from 'react-native-navigation';
import Animated, {runOnJS, useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated';
import {useSafeAreaInsets} from 'react-native-safe-area-context';
@@ -144,43 +144,45 @@ const InAppNotification = ({componentId, serverName, serverUrl, notification}: I
const gesture = Gesture.Pan().activeOffsetY(-20).onStart(() => runOnJS(animateDismissOverlay)());
return (
<GestureDetector gesture={gesture}>
<Animated.View
style={[styles.container, isTablet ? styles.tablet : undefined, animatedStyle]}
testID='in_app_notification.screen'
>
<View style={styles.flex}>
<TouchableOpacity
style={styles.touchable}
onPress={notificationTapped}
activeOpacity={1}
>
<Icon
database={DatabaseManager.serverDatabases[serverUrl].database}
fromWebhook={notification.payload?.from_webhook === 'true'}
overrideIconUrl={notification.payload?.override_icon_url}
senderId={notification.payload?.sender_id || ''}
serverUrl={serverUrl}
useUserIcon={notification.payload?.use_user_icon === 'true'}
/>
<View style={styles.titleContainer}>
<Title channelName={notification.payload?.channel_name || ''}/>
<View style={styles.flex}>
<Text
numberOfLines={2}
ellipsizeMode='tail'
style={styles.message}
testID='in_app_notification.message'
>
{message}
</Text>
<GestureHandlerRootView>
<GestureDetector gesture={gesture}>
<Animated.View
style={[styles.container, isTablet ? styles.tablet : undefined, animatedStyle]}
testID='in_app_notification.screen'
>
<View style={styles.flex}>
<TouchableOpacity
style={styles.touchable}
onPress={notificationTapped}
activeOpacity={1}
>
<Icon
database={DatabaseManager.serverDatabases[serverUrl].database}
fromWebhook={notification.payload?.from_webhook === 'true'}
overrideIconUrl={notification.payload?.override_icon_url}
senderId={notification.payload?.sender_id || ''}
serverUrl={serverUrl}
useUserIcon={notification.payload?.use_user_icon === 'true'}
/>
<View style={styles.titleContainer}>
<Title channelName={notification.payload?.channel_name || ''}/>
<View style={styles.flex}>
<Text
numberOfLines={2}
ellipsizeMode='tail'
style={styles.message}
testID='in_app_notification.message'
>
{message}
</Text>
</View>
{Boolean(serverName) && <Server serverName={serverName!}/>}
</View>
{Boolean(serverName) && <Server serverName={serverName!}/>}
</View>
</TouchableOpacity>
</View>
</Animated.View>
</GestureDetector>
</TouchableOpacity>
</View>
</Animated.View>
</GestureDetector>
</GestureHandlerRootView>
);
};

View File

@@ -90,7 +90,7 @@ Navigation.setLazyComponentRegistrator((screenName) => {
case Screens.IN_APP_NOTIFICATION: {
const notificationScreen = require('@screens/in_app_notification').default;
Navigation.registerComponent(Screens.IN_APP_NOTIFICATION, () => Platform.select({
default: withGestures(notificationScreen, undefined),
default: notificationScreen,
ios: withSafeAreaInsets(notificationScreen),
}));
return;