aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/assets/icons/messages/delivered_icon.pngbin0 -> 65998 bytes
-rw-r--r--src/assets/icons/messages/read_icon.pngbin0 -> 65884 bytes
-rw-r--r--src/assets/icons/messages/sent_icon.pngbin0 -> 56234 bytes
-rw-r--r--src/components/messages/DateHeader.tsx28
-rw-r--r--src/components/messages/MessageFooter.tsx75
-rw-r--r--src/components/messages/index.ts2
-rw-r--r--src/components/notifications/Notification.tsx69
-rw-r--r--src/constants/api.ts1
-rw-r--r--src/screens/badge/BadgeSelection.tsx7
-rw-r--r--src/screens/chat/ChatScreen.tsx27
-rw-r--r--src/screens/profile/ProfileScreen.tsx9
-rw-r--r--src/services/SuggestedPeopleService.ts12
-rw-r--r--src/services/UserProfileService.ts22
-rw-r--r--src/types/types.ts4
-rw-r--r--src/utils/messages.ts25
15 files changed, 248 insertions, 33 deletions
diff --git a/src/assets/icons/messages/delivered_icon.png b/src/assets/icons/messages/delivered_icon.png
new file mode 100644
index 00000000..0afa7e90
--- /dev/null
+++ b/src/assets/icons/messages/delivered_icon.png
Binary files differ
diff --git a/src/assets/icons/messages/read_icon.png b/src/assets/icons/messages/read_icon.png
new file mode 100644
index 00000000..a82b705d
--- /dev/null
+++ b/src/assets/icons/messages/read_icon.png
Binary files differ
diff --git a/src/assets/icons/messages/sent_icon.png b/src/assets/icons/messages/sent_icon.png
new file mode 100644
index 00000000..55988c78
--- /dev/null
+++ b/src/assets/icons/messages/sent_icon.png
Binary files differ
diff --git a/src/components/messages/DateHeader.tsx b/src/components/messages/DateHeader.tsx
new file mode 100644
index 00000000..cc7dce2c
--- /dev/null
+++ b/src/components/messages/DateHeader.tsx
@@ -0,0 +1,28 @@
+import React from 'react';
+import {View, Text, StyleSheet} from 'react-native';
+import {getFormatedDate, normalize} from '../../utils';
+
+interface DateHeaderProps {
+ date: object;
+}
+
+const DateHeader: React.FC<DateHeaderProps> = ({date}) => {
+ return (
+ <View style={styles.dateContainer}>
+ <Text style={styles.dateHeader}>{getFormatedDate(date)}</Text>
+ </View>
+ );
+};
+
+const styles = StyleSheet.create({
+ dateHeader: {
+ color: '#7A7A7A',
+ fontWeight: '600',
+ fontSize: normalize(11),
+ textAlign: 'center',
+ marginVertical: '5%',
+ },
+ dateContainer: {backgroundColor: 'transparent'},
+});
+
+export default DateHeader;
diff --git a/src/components/messages/MessageFooter.tsx b/src/components/messages/MessageFooter.tsx
new file mode 100644
index 00000000..2ed8c6ed
--- /dev/null
+++ b/src/components/messages/MessageFooter.tsx
@@ -0,0 +1,75 @@
+import moment from 'moment';
+import React from 'react';
+import {normalize} from '../../utils';
+import {useMessageContext} from 'stream-chat-react-native-core';
+import {View, Text, Image, StyleSheet} from 'react-native';
+
+const MessageFooter: React.FC = () => {
+ const message = useMessageContext();
+
+ if (message.message.type === 'deleted') {
+ return <></>;
+ } else {
+ const printTime = moment(message.message.created_at).format('h:mmA');
+ if (message.lastGroupMessage) {
+ return (
+ <View
+ style={[
+ message.isMyMessage ? styles.userMessage : styles.userXMessage,
+ styles.generalMessage,
+ ]}>
+ {readReceipts(message)}
+ <Text style={styles.time}>{printTime}</Text>
+ </View>
+ );
+ } else {
+ return <></>;
+ }
+ }
+};
+
+const readReceipts = (message) => {
+ const readByLocal = message.message.readBy;
+ if (message.isMyMessage) {
+ if (readByLocal) {
+ return (
+ <Image
+ source={require('../../assets/icons/messages/read_icon.png')}
+ style={styles.icon}
+ />
+ );
+ } else if (message.message.status === 'received') {
+ return (
+ <Image
+ source={require('../../assets/icons/messages/delivered_icon.png')}
+ style={styles.icon}
+ />
+ );
+ } else if (message.message.status === 'sending') {
+ return (
+ <Image
+ source={require('../../assets/icons/messages/sent_icon.png')}
+ style={styles.icon}
+ />
+ );
+ } else {
+ return <></>;
+ }
+ }
+};
+
+export const styles = StyleSheet.create({
+ time: {
+ fontSize: normalize(11),
+ color: '#7A7A7A',
+ lineHeight: normalize(13),
+ },
+ userMessage: {
+ marginRight: 5,
+ },
+ userXMessage: {marginLeft: 5},
+ generalMessage: {marginTop: 4, flexDirection: 'row'},
+ icon: {width: 15, height: 15},
+});
+
+export default MessageFooter;
diff --git a/src/components/messages/index.ts b/src/components/messages/index.ts
index d08e9454..b19067ca 100644
--- a/src/components/messages/index.ts
+++ b/src/components/messages/index.ts
@@ -5,3 +5,5 @@ export {default as ChatHeader} from './ChatHeader';
export {default as ChatInputSubmit} from './ChatInputSubmit';
export {default as MessageAvatar} from './MessageAvatar';
export {default as TypingIndicator} from './TypingIndicator';
+export {default as MessageFooter} from './MessageFooter';
+export {default as DateHeader} from './DateHeader';
diff --git a/src/components/notifications/Notification.tsx b/src/components/notifications/Notification.tsx
index 8e008cf9..3cc1c7f1 100644
--- a/src/components/notifications/Notification.tsx
+++ b/src/components/notifications/Notification.tsx
@@ -208,6 +208,9 @@ const Notification: React.FC<NotificationProps> = (props) => {
const isOwnProfile = id === loggedInUser.userId;
const navigateToProfile = async () => {
+ if (notification_type === 'SYSTEM_MSG') {
+ return;
+ }
if (!userXInStore(state, screenType, id)) {
await fetchUserX(dispatch, {userId: id, username: username}, screenType);
}
@@ -231,35 +234,47 @@ const Notification: React.FC<NotificationProps> = (props) => {
}
/>
</TouchableWithoutFeedback>
- <View style={styles.contentContainer}>
- <TouchableWithoutFeedback onPress={navigateToProfile}>
- <Text style={styles.actorName}>
- {first_name} {last_name}
- </Text>
- </TouchableWithoutFeedback>
- <TouchableWithoutFeedback onPress={onNotificationTap}>
- <Text>{verbage}</Text>
- </TouchableWithoutFeedback>
- </View>
- {notification_type === 'FRD_REQ' && (
- <View style={styles.buttonsContainer}>
- <AcceptDeclineButtons
- requester={{id, username, first_name, last_name}}
- onAccept={handleAcceptRequest}
- onReject={handleDeclineFriendRequest}
- />
+ {notification_type === 'SYSTEM_MSG' ? (
+ // Only verbage
+ <View style={styles.contentContainer}>
+ <Text style={styles.actorName}>{verbage}</Text>
</View>
+ ) : (
+ <>
+ {/* Text content: Actor name and verbage*/}
+ <View style={styles.contentContainer}>
+ <TouchableWithoutFeedback onPress={navigateToProfile}>
+ <Text style={styles.actorName}>
+ {first_name} {last_name}
+ </Text>
+ </TouchableWithoutFeedback>
+ <TouchableWithoutFeedback onPress={onNotificationTap}>
+ <Text>{verbage}</Text>
+ </TouchableWithoutFeedback>
+ </View>
+ {/* Friend request accept/decline button */}
+ {notification_type === 'FRD_REQ' && (
+ <View style={styles.buttonsContainer}>
+ <AcceptDeclineButtons
+ requester={{id, username, first_name, last_name}}
+ onAccept={handleAcceptRequest}
+ onReject={handleDeclineFriendRequest}
+ />
+ </View>
+ )}
+ {/* Moment Image Preview */}
+ {(notification_type === 'CMT' ||
+ notification_type === 'MOM_3+' ||
+ notification_type === 'MOM_FRIEND') &&
+ notification_object && (
+ <TouchableWithoutFeedback
+ style={styles.moment}
+ onPress={onNotificationTap}>
+ <Image style={styles.imageFlex} source={{uri: momentURI}} />
+ </TouchableWithoutFeedback>
+ )}
+ </>
)}
- {(notification_type === 'CMT' ||
- notification_type === 'MOM_3+' ||
- notification_type === 'MOM_FRIEND') &&
- notification_object && (
- <TouchableWithoutFeedback
- style={styles.moment}
- onPress={onNotificationTap}>
- <Image style={styles.imageFlex} source={{uri: momentURI}} />
- </TouchableWithoutFeedback>
- )}
</View>
);
diff --git a/src/constants/api.ts b/src/constants/api.ts
index cb45b238..dd934f0e 100644
--- a/src/constants/api.ts
+++ b/src/constants/api.ts
@@ -16,6 +16,7 @@ export const EDIT_PROFILE_ENDPOINT: string = API_URL + 'edit-profile/';
export const SEND_OTP_ENDPOINT: string = API_URL + 'send-otp/';
export const VERIFY_OTP_ENDPOINT: string = API_URL + 'verify-otp/';
export const USER_PROFILE_ENDPOINT: string = API_URL + 'profile/';
+export const USER_PROFILE_VISITED_ENDPOINT: string = API_URL + 'profile/visited/';
export const PROFILE_INFO_ENDPOINT: string = API_URL + 'user-profile-info/';
export const HEADER_PHOTO_ENDPOINT: string = API_URL + 'header-pic/';
export const PROFILE_PHOTO_ENDPOINT: string = API_URL + 'profile-pic/';
diff --git a/src/screens/badge/BadgeSelection.tsx b/src/screens/badge/BadgeSelection.tsx
index deaefb52..2fec8ea3 100644
--- a/src/screens/badge/BadgeSelection.tsx
+++ b/src/screens/badge/BadgeSelection.tsx
@@ -66,13 +66,16 @@ const BadgeSelection: React.FC<BadgeSelectionProps> = ({route}) => {
style={styles.rightButtonContainer}
onPress={async () => {
if (editing) {
- updateBadgesService(selectedBadges);
+ updateBadgesService(selectedBadges, university);
navigation.navigate('UpdateSPPicture', {
editing: true,
});
} else {
if (selectedBadges.length !== 0) {
- const success = await addBadgesService(selectedBadges);
+ const success = await addBadgesService(
+ selectedBadges,
+ university,
+ );
if (success) {
dispatch(suggestedPeopleBadgesFinished());
navigation.navigate('SuggestedPeople');
diff --git a/src/screens/chat/ChatScreen.tsx b/src/screens/chat/ChatScreen.tsx
index 656c1c47..57f2232e 100644
--- a/src/screens/chat/ChatScreen.tsx
+++ b/src/screens/chat/ChatScreen.tsx
@@ -16,7 +16,9 @@ import {ChatContext} from '../../App';
import {
ChatHeader,
ChatInput,
+ DateHeader,
MessageAvatar,
+ MessageFooter,
TabsGradient,
TypingIndicator,
} from '../../components';
@@ -37,6 +39,9 @@ const ChatScreen: React.FC<ChatScreenProps> = () => {
const {setTopInset} = useAttachmentPickerContext();
const insets = useSafeAreaInsets();
const chatTheme: DeepPartial<Theme> = {
+ colors: {
+ accent_blue: '#6EE7E7',
+ },
messageList: {
container: {
backgroundColor: 'white',
@@ -70,6 +75,24 @@ const ChatScreen: React.FC<ChatScreenProps> = () => {
flexDirection: 'row',
},
content: {
+ deletedContainer: {},
+ deletedContainerInner: {
+ borderColor: 'transparent',
+ borderBottomLeftRadius: 10,
+ borderTopLeftRadius: 10,
+ borderBottomRightRadius: 10,
+ borderTopRightRadius: 10,
+ },
+ deletedMetaText: {
+ paddingHorizontal: 10,
+ },
+ deletedText: {
+ em: {
+ fontSize: 15,
+ fontStyle: 'italic',
+ fontWeight: '400',
+ },
+ },
metaContainer: {
marginLeft: 5,
},
@@ -123,6 +146,10 @@ const ChatScreen: React.FC<ChatScreenProps> = () => {
copyMessage,
deleteMessage,
]}
+ InlineDateSeparator={DateHeader}
+ StickyHeader={() => null}
+ ScrollToBottomButton={() => null}
+ MessageFooter={MessageFooter}
TypingIndicator={TypingIndicator}
myMessageTheme={loggedInUsersMessageTheme}
MessageAvatar={MessageAvatar}>
diff --git a/src/screens/profile/ProfileScreen.tsx b/src/screens/profile/ProfileScreen.tsx
index 6d9ef020..3dd142e1 100644
--- a/src/screens/profile/ProfileScreen.tsx
+++ b/src/screens/profile/ProfileScreen.tsx
@@ -1,8 +1,9 @@
-import React from 'react';
+import React, {useEffect} from 'react';
import {StatusBar} from 'react-native';
import {Content, TabsGradient} from '../../components';
import {RouteProp} from '@react-navigation/native';
import {MainStackParams} from '../../routes/';
+import {visitedUserProfile} from '../../services';
type ProfileScreenRouteProps = RouteProp<MainStackParams, 'Profile'>;
@@ -14,6 +15,12 @@ const ProfileScreen: React.FC<ProfileOnboardingProps> = ({route}) => {
const {screenType} = route.params;
let {userXId} = route.params;
+ useEffect(() => {
+ if (userXId) {
+ visitedUserProfile(userXId);
+ }
+ });
+
return (
<>
<StatusBar barStyle="dark-content" />
diff --git a/src/services/SuggestedPeopleService.ts b/src/services/SuggestedPeopleService.ts
index 4f56feb9..617f3970 100644
--- a/src/services/SuggestedPeopleService.ts
+++ b/src/services/SuggestedPeopleService.ts
@@ -136,11 +136,15 @@ export const getMutualBadgeHolders = async (badge_id: string) => {
}
};
-export const addBadgesService = async (selectedBadges: string[]) => {
+export const addBadgesService = async (
+ selectedBadges: string[],
+ university: string,
+) => {
try {
const token = await AsyncStorage.getItem('token');
const form = new FormData();
form.append('badges', JSON.stringify(selectedBadges));
+ form.append('university', JSON.stringify(university));
const response = await fetch(ADD_BADGES_ENDPOINT, {
method: 'POST',
headers: {
@@ -161,11 +165,15 @@ export const addBadgesService = async (selectedBadges: string[]) => {
}
};
-export const updateBadgesService = async (selectedBadges: string[]) => {
+export const updateBadgesService = async (
+ selectedBadges: string[],
+ university: string,
+) => {
try {
const token = await AsyncStorage.getItem('token');
const form = new FormData();
form.append('badges', JSON.stringify(selectedBadges));
+ form.append('university', JSON.stringify(university));
const response = await fetch(UPDATE_BADGES_ENDPOINT, {
method: 'POST',
headers: {
diff --git a/src/services/UserProfileService.ts b/src/services/UserProfileService.ts
index 1ce1d0b5..a2237c94 100644
--- a/src/services/UserProfileService.ts
+++ b/src/services/UserProfileService.ts
@@ -16,6 +16,7 @@ import {
SEND_OTP_ENDPOINT,
TAGG_CUSTOMER_SUPPORT,
USER_PROFILE_ENDPOINT,
+ USER_PROFILE_VISITED_ENDPOINT,
VERIFY_OTP_ENDPOINT,
} from '../constants';
import {
@@ -412,3 +413,24 @@ export const patchEditProfile = async (form: FormData, userId: string) => {
throw ERROR_DOUBLE_CHECK_CONNECTION;
}
};
+
+export const visitedUserProfile = async (userId: string) => {
+ try {
+ const token = await AsyncStorage.getItem('token');
+ const form = new FormData();
+ form.append('user_id', userId);
+ const response = await fetch(USER_PROFILE_VISITED_ENDPOINT, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'multipart/form-data',
+ Authorization: 'Token ' + token,
+ },
+ body: form,
+ });
+ if (response.status !== 200) {
+ console.error('Failed to submit a profile visit');
+ }
+ } catch (error) {
+ return undefined;
+ }
+};
diff --git a/src/types/types.ts b/src/types/types.ts
index 376c4be0..8d7f4aed 100644
--- a/src/types/types.ts
+++ b/src/types/types.ts
@@ -251,7 +251,9 @@ export type TypeOfNotification =
// notification_object is MomentType
| 'MOM_FRIEND'
// notification_object is undefined
- | 'INVT_ONBRD';
+ | 'INVT_ONBRD'
+ // notification_object is undefined
+ | 'SYSTEM_MSG';
export type UniversityBadge = {
id: number;
diff --git a/src/utils/messages.ts b/src/utils/messages.ts
index f4215bf0..0e73f639 100644
--- a/src/utils/messages.ts
+++ b/src/utils/messages.ts
@@ -137,3 +137,28 @@ export const createChannel = async (
throw error;
}
};
+
+export const getFormatedDate = (date: object) => {
+ const dateMoment = moment(date).startOf('day');
+ let dateToRender = '';
+
+ const TODAY = moment().startOf('day');
+ const YESTERDAY = moment().subtract(1, 'day').startOf('day');
+ const LAST_7_DAYS = moment().subtract(7, 'day').startOf('day');
+
+ if (TODAY.isSame(dateMoment)) {
+ dateToRender = 'Today';
+ } else if (YESTERDAY.isSame(dateMoment)) {
+ dateToRender = 'Yesterday';
+ } else if (dateMoment.isBetween(LAST_7_DAYS, YESTERDAY)) {
+ dateToRender = dateMoment.format('dddd');
+ } else {
+ if (dateMoment.get('year') === TODAY.get('year')) {
+ dateToRender = dateMoment.format('MMMM D') + 'th';
+ } else {
+ dateToRender =
+ dateMoment.format('MMMM D ') + 'th' + dateMoment.get('year');
+ }
+ }
+ return dateToRender;
+};