Skip to content

Commit

Permalink
Automated cherry pick of #8568 (#8572)
Browse files Browse the repository at this point in the history
* MM-62915 and MM-62919 (#8568)

(cherry picked from commit ee66890)

* remove duplicate backgroundColor in search results header

---------

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
  • Loading branch information
mattermost-build and enahum authored Feb 7, 2025
1 parent 3d3542f commit b00c550
Show file tree
Hide file tree
Showing 18 changed files with 200 additions and 168 deletions.
10 changes: 7 additions & 3 deletions android/app/src/main/java/com/mattermost/helpers/Network.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import com.mattermost.networkclient.ApiClientModuleImpl;
import com.mattermost.networkclient.enums.RetryTypes;
import com.mattermost.turbolog.TurboLog;

import okhttp3.HttpUrl;
import okhttp3.Response;
Expand All @@ -21,9 +22,12 @@ public class Network {
private static final Promise emptyPromise = new ResolvePromise();

public static void init(Context context) {
final ReactApplicationContext reactContext = (ApiClientModuleImpl.context == null) ? (ReactApplicationContext) context.getApplicationContext() : ApiClientModuleImpl.context;
clientModule = new ApiClientModuleImpl(reactContext);
createClientOptions();
if (clientModule == null) {
clientModule = new ApiClientModuleImpl(context);
createClientOptions();
} else {
TurboLog.Companion.i("ReactNative", "Network already initialized");
}
}

public static void get(String baseUrl, String endpoint, ReadableMap options, Promise promise) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class CustomPushNotification(
init {
try {
DatabaseHelper.instance?.init(context)
Network.init(context)
NotificationHelper.cleanNotificationPreferencesIfNeeded(context)
} catch (e: Exception) {
e.printStackTrace()
Expand All @@ -51,6 +50,7 @@ class CustomPushNotification(
val isIdLoaded = initialData.getString("id_loaded") == "true"
val notificationId = NotificationHelper.getNotificationId(initialData)
val serverUrl = addServerUrlToBundle(initialData)
Network.init(mContext)

GlobalScope.launch {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,32 @@
import androidx.core.app.NotificationCompat;
import androidx.core.app.Person;

import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.WritableMap;

import com.mattermost.helpers.*;
import com.mattermost.turbolog.TurboLog;
import com.wix.reactnativenotifications.core.NotificationIntentAdapter;
import com.wix.reactnativenotifications.core.notification.INotificationsApplication;
import com.wix.reactnativenotifications.core.notification.PushNotificationProps;

public class NotificationReplyBroadcastReceiver extends BroadcastReceiver {
private Context mContext;
private Bundle bundle;
private NotificationManager notificationManager;

private ReactApplicationContext getReactContext(Context context) {
if (context instanceof ReactApplication) {
ReactNativeHost host = ((ReactApplication) context).getReactNativeHost();
return (ReactApplicationContext) host.getReactInstanceManager().getCurrentReactContext();
}

return null;
}

@Override
public void onReceive(Context context, Intent intent) {
try {
Expand All @@ -40,6 +53,7 @@ public void onReceive(Context context, Intent intent) {

final int notificationId = intent.getIntExtra(CustomPushNotificationHelper.NOTIFICATION_ID, -1);
final String serverUrl = bundle.getString("server_url");
Network.init(context);
if (serverUrl != null) {
replyToMessage(serverUrl, notificationId, message);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ exports[`components/channel_list/categories/body/channel_item should match snaps
"lineHeight": 24,
},
{
"color": "#ffffff",
"color": "rgba(255,255,255,0.72)",
},
false,
null,
Expand Down Expand Up @@ -213,7 +213,7 @@ exports[`components/channel_list/categories/body/channel_item should match snaps
"lineHeight": 24,
},
{
"color": "#ffffff",
"color": "rgba(255,255,255,0.72)",
},
false,
null,
Expand Down Expand Up @@ -251,7 +251,7 @@ exports[`components/channel_list/categories/body/channel_item should match snaps
"lineHeight": 24,
},
{
"color": "#ffffff",
"color": "rgba(255,255,255,0.72)",
},
false,
null,
Expand Down Expand Up @@ -361,7 +361,7 @@ exports[`components/channel_list/categories/body/channel_item should match snaps
"lineHeight": 24,
},
{
"color": "#ffffff",
"color": "rgba(255,255,255,0.72)",
},
false,
null,
Expand Down
2 changes: 1 addition & 1 deletion app/components/channel_item/channel_item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({
marginRight: 12,
},
text: {
color: theme.sidebarText,
color: changeOpacity(theme.sidebarText, 0.72),
},
highlight: {
color: theme.sidebarUnreadText,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ exports[`Thread item in the channel list Threads Component should match snapshot
"lineHeight": 24,
},
{
"color": "#ffffff",
"color": "rgba(255,255,255,0.72)",
},
false,
false,
Expand Down Expand Up @@ -174,7 +174,7 @@ exports[`Thread item in the channel list Threads Component should match snapshot
"lineHeight": 24,
},
{
"color": "#ffffff",
"color": "rgba(255,255,255,0.72)",
},
false,
false,
Expand Down
48 changes: 24 additions & 24 deletions app/screens/home/account/account.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import {useRoute} from '@react-navigation/native';
import {useIsFocused, useRoute} from '@react-navigation/native';
import React, {useCallback, useState} from 'react';
import {Freeze} from 'react-freeze';
import {ScrollView, View} from 'react-native';
import Animated, {useAnimatedStyle, withTiming} from 'react-native-reanimated';
import {type Edge, SafeAreaView, useSafeAreaInsets} from 'react-native-safe-area-context';
Expand All @@ -28,10 +29,6 @@ const edges: Edge[] = ['left', 'right'];

const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => {
return {
container: {
flex: 1,
backgroundColor: theme.sidebarBg,
},
flex: {
flex: 1,
},
Expand Down Expand Up @@ -62,6 +59,7 @@ const AccountScreen = ({currentUser, enableCustomUserStatuses, showFullName}: Ac
const route = useRoute();
const insets = useSafeAreaInsets();
const isTablet = useIsTablet();
const isFocused = useIsFocused();

let tabletSidebarStyle;
if (isTablet) {
Expand Down Expand Up @@ -113,27 +111,29 @@ const AccountScreen = ({currentUser, enableCustomUserStatuses, showFullName}: Ac
) : null;

return (
<SafeAreaView
edges={edges}
style={styles.container}
testID='account.screen'
>
<View style={[{height: insets.top, flexDirection: 'row'}]}>
<View style={[styles.container, tabletSidebarStyle]}/>
{isTablet && <View style={styles.tabletContainer}/>}
</View>
<Animated.View
onLayout={onLayout}
style={[styles.flexRow, animated]}
<Freeze freeze={!isFocused}>
<SafeAreaView
edges={edges}
style={styles.flex}
testID='account.screen'
>
{content}
{isTablet &&
<View style={[styles.tabletContainer, styles.tabletDivider]}>
<AccountTabletView/>
<View style={[{height: insets.top, flexDirection: 'row'}]}>
<View style={[styles.flex, tabletSidebarStyle]}/>
{isTablet && <View style={styles.tabletContainer}/>}
</View>
}
</Animated.View>
</SafeAreaView>
<Animated.View
onLayout={onLayout}
style={[styles.flexRow, animated]}
>
{content}
{isTablet &&
<View style={[styles.tabletContainer, styles.tabletDivider]}>
<AccountTabletView/>
</View>
}
</Animated.View>
</SafeAreaView>
</Freeze>
);
};

Expand Down
91 changes: 44 additions & 47 deletions app/screens/home/recent_mentions/recent_mentions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

import {useIsFocused, useRoute} from '@react-navigation/native';
import React, {useCallback, useState, useEffect, useMemo} from 'react';
import {Freeze} from 'react-freeze';
import {useIntl} from 'react-intl';
import {ActivityIndicator, DeviceEventEmitter, type ListRenderItemInfo, View} from 'react-native';
import {ActivityIndicator, DeviceEventEmitter, type ListRenderItemInfo, StyleSheet, View} from 'react-native';
import Animated, {useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated';
import {SafeAreaView, type Edge} from 'react-native-safe-area-context';

Expand All @@ -19,7 +20,6 @@ import {useServerUrl} from '@context/server';
import {useTheme} from '@context/theme';
import {useCollapsibleHeader} from '@hooks/header';
import {getDateForDateLine, selectOrderedPosts} from '@utils/post_list';
import {makeStyleSheetFromTheme} from '@utils/theme';

import EmptyState from './components/empty';

Expand All @@ -35,20 +35,16 @@ type Props = {
mentions: PostModel[];
}

const getStyleSheet = makeStyleSheetFromTheme((theme) => ({
const styles = StyleSheet.create({
flex: {
flex: 1,
backgroundColor: theme.centerChannelBg,
},
container: {
flex: 1,
},
empty: {
alignItems: 'center',
flex: 1,
justifyContent: 'center',
},
}));
});

const RecentMentionsScreen = ({appsEnabled, customEmojiNames, mentions, currentTimezone}: Props) => {
const theme = useTheme();
Expand All @@ -58,7 +54,6 @@ const RecentMentionsScreen = ({appsEnabled, customEmojiNames, mentions, currentT
const [refreshing, setRefreshing] = useState(false);
const [loading, setLoading] = useState(true);
const serverUrl = useServerUrl();
const styles = getStyleSheet(theme);

const params = route.params as {direction: string};
const toLeft = params.direction === 'left';
Expand Down Expand Up @@ -165,45 +160,47 @@ const RecentMentionsScreen = ({appsEnabled, customEmojiNames, mentions, currentT
}, [appsEnabled, customEmojiNames]);

return (
<ExtraKeyboardProvider>
<NavigationHeader
isLargeTitle={true}
showBackButton={false}
subtitle={subtitle}
title={title}
hasSearch={false}
scrollValue={scrollValue}
/>
<SafeAreaView
style={styles.flex}
edges={EDGES}
testID='recent_mentions.screen'
>
<Animated.View style={[styles.container, animated]}>
<Animated.View style={top}>
<RoundedHeaderContext/>
<Freeze freeze={!isFocused}>
<ExtraKeyboardProvider>
<NavigationHeader
isLargeTitle={true}
showBackButton={false}
subtitle={subtitle}
title={title}
hasSearch={false}
scrollValue={scrollValue}
/>
<SafeAreaView
style={styles.flex}
edges={EDGES}
testID='recent_mentions.screen'
>
<Animated.View style={[styles.flex, animated]}>
<Animated.View style={top}>
<RoundedHeaderContext/>
</Animated.View>
<Animated.FlatList
ref={scrollRef}
contentContainerStyle={paddingTop}
ListEmptyComponent={renderEmptyList()}
data={posts}
scrollToOverflowEnabled={true}
showsVerticalScrollIndicator={false}
progressViewOffset={scrollPaddingTop}
scrollEventThrottle={16}
indicatorStyle='black'
onScroll={onScroll}
onRefresh={handleRefresh}
refreshing={refreshing}
renderItem={renderItem}
removeClippedSubviews={true}
onViewableItemsChanged={onViewableItemsChanged}
testID='recent_mentions.post_list.flat_list'
/>
</Animated.View>
<Animated.FlatList
ref={scrollRef}
contentContainerStyle={paddingTop}
ListEmptyComponent={renderEmptyList()}
data={posts}
scrollToOverflowEnabled={true}
showsVerticalScrollIndicator={false}
progressViewOffset={scrollPaddingTop}
scrollEventThrottle={16}
indicatorStyle='black'
onScroll={onScroll}
onRefresh={handleRefresh}
refreshing={refreshing}
renderItem={renderItem}
removeClippedSubviews={true}
onViewableItemsChanged={onViewableItemsChanged}
testID='recent_mentions.post_list.flat_list'
/>
</Animated.View>
</SafeAreaView>
</ExtraKeyboardProvider>
</SafeAreaView>
</ExtraKeyboardProvider>
</Freeze>
);
};

Expand Down
Loading

0 comments on commit b00c550

Please sign in to comment.