Browse Source

headers for images && removed "is-feature-active"

Viktoriia 3 months ago
parent
commit
ba5eff300f

+ 11 - 15
src/components/MenuDrawer/index.tsx

@@ -22,13 +22,11 @@ import BagIcon from 'assets/icons/bag.svg';
 import { APP_VERSION } from 'src/constants';
 import { useMessagesStore } from 'src/stores/unreadMessagesStore';
 import { SafeAreaView } from 'react-native-safe-area-context';
-import { usePostIsFeatureActiveQuery } from '@api/location';
 import { useFriendsNotificationsStore } from 'src/stores/friendsNotificationsStore';
 
 export const MenuDrawer = (props: any) => {
   const { mutate: deleteUser } = useDeleteUserMutation();
   const token = storage.get('token', StoreType.STRING) as string;
-  const { data: isFeatureActive } = usePostIsFeatureActiveQuery(token, !!token);
   const navigation = useNavigation();
   const [modalInfo, setModalInfo] = useState({
     visible: false,
@@ -113,19 +111,17 @@ export const MenuDrawer = (props: any) => {
               }
             />
           )}
-          {isFeatureActive && isFeatureActive.active && (
-            <MenuButton
-              label="Location sharing"
-              icon={<SharingIcon fill={Colors.DARK_BLUE} width={20} height={20} />}
-              red={false}
-              buttonFn={() =>
-                // @ts-ignore
-                navigation.navigate(NAVIGATION_PAGES.MENU_DRAWER, {
-                  screen: NAVIGATION_PAGES.LOCATION_SHARING
-                })
-              }
-            />
-          )}
+          <MenuButton
+            label="Location sharing"
+            icon={<SharingIcon fill={Colors.DARK_BLUE} width={20} height={20} />}
+            red={false}
+            buttonFn={() =>
+              // @ts-ignore
+              navigation.navigate(NAVIGATION_PAGES.MENU_DRAWER, {
+                screen: NAVIGATION_PAGES.LOCATION_SHARING
+              })
+            }
+          />
           <MenuButton
             label="Shop"
             icon={<BagIcon fill={Colors.DARK_BLUE} width={20} height={20} />}

+ 0 - 6
src/modules/api/location/location-api.ts

@@ -11,10 +11,6 @@ export interface PostGetUsersLocationReturn extends ResponseType {
   geojson: GeoJSON.FeatureCollection;
 }
 
-export interface PostIsFeatureActiveReturn extends ResponseType {
-  active: boolean;
-}
-
 export interface PostGetUserCountReturn extends ResponseType {
   count: number;
 }
@@ -28,8 +24,6 @@ export const locationApi = {
     request.postForm<ResponseType>(API.UPDATE_LOCATION, { token, lat, lng }),
   getUsersLocation: (token: string) =>
     request.postForm<PostGetUsersLocationReturn>(API.GET_USERS_LOCATION, { token }),
-  isFeatureActive: (token: string) =>
-    request.postForm<PostIsFeatureActiveReturn>(API.IS_FEATURE_ACTIVE, { token }),
   getUsersCount: (token: string) =>
     request.postForm<PostGetUserCountReturn>(API.GET_USERS_COUNT, { token })
 };

+ 0 - 1
src/modules/api/location/location-query-keys.tsx

@@ -3,6 +3,5 @@ export const locationQueryKeys = {
   setSettings: () => ['location', 'setSettings'],
   updateLocation: () => ['location', 'updateLocation'],
   getUsersLocation: (token: string) => ['location', 'getUsersLocation', token],
-  isFeatureActive: (token: string) => ['location', 'isFeatureActive', token],
   getUsersCount: (token: string) => ['location', 'getUsersCount', token]
 };

+ 0 - 1
src/modules/api/location/queries/index.ts

@@ -2,5 +2,4 @@ export * from './use-post-get-settings';
 export * from './use-post-set-settings';
 export * from './use-post-update-location';
 export * from './use-post-get-users-location';
-export * from './use-post-is-feature-active';
 export * from './use-post-get-users-on-map-count';

+ 0 - 17
src/modules/api/location/queries/use-post-is-feature-active.tsx

@@ -1,17 +0,0 @@
-import { useQuery } from '@tanstack/react-query';
-
-import { locationQueryKeys } from '../location-query-keys';
-import { locationApi, type PostIsFeatureActiveReturn } from '../location-api';
-
-import type { BaseAxiosError } from '../../../../types';
-
-export const usePostIsFeatureActiveQuery = (token: string, enabled: boolean) => {
-  return useQuery<PostIsFeatureActiveReturn, BaseAxiosError>({
-    queryKey: locationQueryKeys.isFeatureActive(token),
-    queryFn: async () => {
-      const response = await locationApi.isFeatureActive(token);
-      return response.data;
-    },
-    enabled
-  });
-};

+ 23 - 7
src/screens/InAppScreens/MessagesScreen/ChatScreen/index.tsx

@@ -12,7 +12,8 @@ import {
   ActivityIndicator,
   AppState,
   AppStateStatus,
-  TextInput
+  TextInput,
+  Platform
 } from 'react-native';
 import {
   GiftedChat,
@@ -49,7 +50,7 @@ import {
   usePostSendMessageMutation
 } from '@api/chat';
 import { CustomMessage, Message, Reaction } from '../types';
-import { API_HOST, WEBSOCKET_URL } from 'src/constants';
+import { API_HOST, APP_VERSION, WEBSOCKET_URL } from 'src/constants';
 import ReactionBar from '../Components/ReactionBar';
 import OptionsMenu from '../Components/OptionsMenu';
 import EmojiSelectorModal from '../Components/EmojiSelectorModal';
@@ -442,7 +443,7 @@ const ChatScreen = ({ route }: { route: any }) => {
       }
 
       const { uri: localUri } = await FileSystem.downloadAsync(uri, fileUri, {
-        headers: { Nmtoken: token }
+        headers: { Nmtoken: token, 'App-Version': APP_VERSION, Platform: Platform.OS }
       });
 
       await FileViewer.open(localUri, {
@@ -474,7 +475,9 @@ const ChatScreen = ({ route }: { route: any }) => {
         return;
       }
 
-      const downloadOptions = currentMessage.video ? { headers: { Nmtoken: token } } : undefined;
+      const downloadOptions = currentMessage.video
+        ? { headers: { Nmtoken: token, 'App-Version': APP_VERSION, Platform: Platform.OS } }
+        : undefined;
       const { uri } = await FileSystem.downloadAsync(fileUrl, fileUri, downloadOptions);
 
       await MediaLibrary.createAssetAsync(uri);
@@ -1483,7 +1486,7 @@ const ChatScreen = ({ route }: { route: any }) => {
     setSelectedMedia(uri);
 
     const { uri: localUri } = await FileSystem.downloadAsync(uri, fileUri, {
-      headers: { Nmtoken: token }
+      headers: { Nmtoken: token, 'App-Version': APP_VERSION, Platform: Platform.OS }
     });
   };
 
@@ -1507,7 +1510,14 @@ const ChatScreen = ({ route }: { route: any }) => {
         style={styles.imageContainer}
         disabled={currentMessage.isSending}
       >
-        <Image source={{ uri: currentMessage.image }} style={styles.chatImage} resizeMode="cover" />
+        <Image
+          source={{
+            uri: currentMessage.image,
+            headers: { Nmtoken: token, 'App-Version': APP_VERSION, Platform: Platform.OS }
+          }}
+          style={styles.chatImage}
+          resizeMode="cover"
+        />
         {currentMessage.isSending && (
           <View
             style={{
@@ -1866,7 +1876,13 @@ const ChatScreen = ({ route }: { route: any }) => {
         )}
 
         <ImageView
-          images={[{ uri: selectedMedia, cache: 'force-cache' }]}
+          images={[
+            {
+              uri: selectedMedia,
+              cache: 'force-cache',
+              headers: { Nmtoken: token, 'App-Version': APP_VERSION, Platform: Platform.OS }
+            }
+          ]}
           imageIndex={0}
           visible={!!selectedMedia}
           onRequestClose={() => setSelectedMedia(null)}

+ 5 - 3
src/screens/InAppScreens/MessagesScreen/Components/renderMessageVideo.tsx

@@ -1,11 +1,11 @@
 import React, { useState, useEffect, useRef } from 'react';
-import { View, ActivityIndicator, TouchableOpacity } from 'react-native';
+import { View, ActivityIndicator, TouchableOpacity, Platform } from 'react-native';
 import { ResizeMode, Video } from 'expo-av';
 import { MaterialCommunityIcons } from '@expo/vector-icons';
 import * as FileSystem from 'expo-file-system';
 import { Colors } from 'src/theme';
 import { CACHED_ATTACHMENTS_DIR } from 'src/constants/constants';
-import { API_HOST } from 'src/constants';
+import { API_HOST, APP_VERSION } from 'src/constants';
 
 const RenderMessageVideo = ({
   props,
@@ -66,7 +66,9 @@ const RenderMessageVideo = ({
 
       const downloadResult = await FileSystem.downloadAsync(videoUrl, videoPath, {
         headers: {
-          Nmtoken: token
+          Nmtoken: token,
+          'App-Version': APP_VERSION,
+          Platform: Platform.OS
         }
       });
 

+ 23 - 7
src/screens/InAppScreens/MessagesScreen/GroupChatScreen/index.tsx

@@ -12,7 +12,8 @@ import {
   ActivityIndicator,
   AppState,
   AppStateStatus,
-  TextInput
+  TextInput,
+  Platform
 } from 'react-native';
 import {
   GiftedChat,
@@ -57,7 +58,7 @@ import {
   usePostGetGroupMembersQuery
 } from '@api/chat';
 import { CustomMessage, GroupMessage, Reaction } from '../types';
-import { API_HOST, WEBSOCKET_URL } from 'src/constants';
+import { API_HOST, APP_VERSION, WEBSOCKET_URL } from 'src/constants';
 import ReactionBar from '../Components/ReactionBar';
 import OptionsMenu from '../Components/OptionsMenu';
 import EmojiSelectorModal from '../Components/EmojiSelectorModal';
@@ -488,7 +489,7 @@ const GroupChatScreen = ({ route }: { route: any }) => {
       }
 
       const { uri: localUri } = await FileSystem.downloadAsync(uri, fileUri, {
-        headers: { Nmtoken: token }
+        headers: { Nmtoken: token, 'App-Version': APP_VERSION, Platform: Platform.OS }
       });
 
       await FileViewer.open(localUri, {
@@ -520,7 +521,9 @@ const GroupChatScreen = ({ route }: { route: any }) => {
         return;
       }
 
-      const downloadOptions = currentMessage.video ? { headers: { Nmtoken: token } } : undefined;
+      const downloadOptions = currentMessage.video
+        ? { headers: { Nmtoken: token, 'App-Version': APP_VERSION, Platform: Platform.OS } }
+        : undefined;
       const { uri } = await FileSystem.downloadAsync(fileUrl, fileUri, downloadOptions);
 
       await MediaLibrary.createAssetAsync(uri);
@@ -1661,7 +1664,7 @@ const GroupChatScreen = ({ route }: { route: any }) => {
     setSelectedMedia(uri);
 
     const { uri: localUri } = await FileSystem.downloadAsync(uri, fileUri, {
-      headers: { Nmtoken: token }
+      headers: { Nmtoken: token, 'App-Version': APP_VERSION, Platform: Platform.OS }
     });
   };
 
@@ -1685,7 +1688,14 @@ const GroupChatScreen = ({ route }: { route: any }) => {
         style={styles.imageContainer}
         disabled={currentMessage.isSending}
       >
-        <Image source={{ uri: currentMessage.image }} style={styles.chatImage} resizeMode="cover" />
+        <Image
+          source={{
+            uri: currentMessage.image,
+            headers: { Nmtoken: token, 'App-Version': APP_VERSION, Platform: Platform.OS }
+          }}
+          style={styles.chatImage}
+          resizeMode="cover"
+        />
         {currentMessage.isSending && (
           <View
             style={{
@@ -2204,7 +2214,13 @@ const GroupChatScreen = ({ route }: { route: any }) => {
         )}
 
         <ImageView
-          images={[{ uri: selectedMedia, cache: 'force-cache' }]}
+          images={[
+            {
+              uri: selectedMedia,
+              cache: 'force-cache',
+              headers: { Nmtoken: token, 'App-Version': APP_VERSION, Platform: Platform.OS }
+            }
+          ]}
           imageIndex={0}
           visible={!!selectedMedia}
           onRequestClose={() => setSelectedMedia(null)}

+ 0 - 2
src/types/api.ts

@@ -155,7 +155,6 @@ export enum API_ENDPOINT {
   SET_LOCATION_SETTINGS = 'set-settings',
   UPDATE_LOCATION = 'update-location',
   GET_USERS_LOCATION = 'get-users-location',
-  IS_FEATURE_ACTIVE = 'is-feature-active',
   AUTHENTICATE = 'authenticate',
   REPORT_CONVERSATION = 'report-conversation',
   GET_USERS_COUNT = 'get-users-on-map-count',
@@ -313,7 +312,6 @@ export enum API {
   SET_LOCATION_SETTINGS = `${API_ROUTE.LOCATION}/${API_ENDPOINT.SET_LOCATION_SETTINGS}`,
   UPDATE_LOCATION = `${API_ROUTE.LOCATION}/${API_ENDPOINT.UPDATE_LOCATION}`,
   GET_USERS_LOCATION = `${API_ROUTE.LOCATION}/${API_ENDPOINT.GET_USERS_LOCATION}`,
-  IS_FEATURE_ACTIVE = `${API_ROUTE.LOCATION}/${API_ENDPOINT.IS_FEATURE_ACTIVE}`,
   AUTHENTICATE = `${API_ROUTE.USER}/${API_ENDPOINT.AUTHENTICATE}`,
   REPORT_CONVERSATION = `${API_ROUTE.CHAT}/${API_ENDPOINT.REPORT_CONVERSATION}`,
   GET_USERS_COUNT = `${API_ROUTE.LOCATION}/${API_ENDPOINT.GET_USERS_COUNT}`,