aboutsummaryrefslogtreecommitdiff
path: root/src/components/notifications
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-05-20 23:47:13 -0400
committerIvan Chen <ivan@tagg.id>2021-05-20 23:47:13 -0400
commit1530471e395eeae5a1de45aa7a2eaa054343b6af (patch)
treed8473aeee46ce96b2832655b693d715a70bb651d /src/components/notifications
parenta472f6387b9530ce440cb02101b5b778875f04a1 (diff)
Clean up code
Diffstat (limited to 'src/components/notifications')
-rw-r--r--src/components/notifications/Notification.tsx151
1 files changed, 74 insertions, 77 deletions
diff --git a/src/components/notifications/Notification.tsx b/src/components/notifications/Notification.tsx
index b0692c9e..3f9cc56a 100644
--- a/src/components/notifications/Notification.tsx
+++ b/src/components/notifications/Notification.tsx
@@ -238,91 +238,88 @@ const Notification: React.FC<NotificationProps> = (props) => {
style={styles.avatarContainer}>
<Avatar style={styles.avatar} uri={avatar} />
</TouchableWithoutFeedback>
- <>
- {/* Text content: Actor name and verbage*/}
- {notification_type === 'SYSTEM_MSG' ||
- notification_type === 'MOM_TAG' ? (
- // Only verbage
- <View style={styles.contentContainer}>
- <View style={styles.textContainerStyles}>
- {notification_type === 'SYSTEM_MSG' ? (
- <Text style={styles.actorName}>{verbage}</Text>
- ) : (
- <Text>
- <Text style={styles.actorName}>{notification_title} </Text>
- <Text style={styles.verbageStyles}>{verbage} </Text>
- <Text style={styles.timeStampStyles}>
- {getTimeInShorthand(timestamp)}
- </Text>
- </Text>
- )}
- </View>
- </View>
- ) : (
- <View style={styles.contentContainer}>
- <TouchableWithoutFeedback onPress={navigateToProfile}>
- <Text style={styles.actorName}>{notification_title}</Text>
- </TouchableWithoutFeedback>
- <TouchableWithoutFeedback
- style={styles.textContainerStyles}
- onPress={onNotificationTap}>
+ {notification_type === 'SYSTEM_MSG' || notification_type === 'MOM_TAG' ? (
+ // Single-line body text with timestamp
+ <View style={styles.contentContainer}>
+ <View style={styles.textContainerStyles}>
+ {notification_type === 'SYSTEM_MSG' ? (
+ <Text style={styles.actorName}>{verbage}</Text>
+ ) : (
<Text>
+ <Text style={styles.actorName}>{notification_title} </Text>
<Text style={styles.verbageStyles}>{verbage} </Text>
<Text style={styles.timeStampStyles}>
{getTimeInShorthand(timestamp)}
</Text>
</Text>
- {/* <Text style={styles.verbageStyles}>{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>
- )}
- {notification_type === 'FRD_ACPT' && (
- <View style={styles.buttonsContainer}>
- <MessageButton
- userXId={id}
- isBlocked={false}
- friendship_status={'friends'}
- externalStyles={{
- container: {
- width: normalize(63),
- height: normalize(21),
- marginTop: '7%',
- },
- buttonTitle: {
- fontSize: normalize(11),
- lineHeight: normalize(13.13),
- letterSpacing: normalize(0.5),
- fontWeight: '700',
- textAlign: 'center',
- },
- }}
- solid
- />
+ )}
</View>
+ </View>
+ ) : (
+ // Two-line title and body text with timestamp
+ <View style={styles.contentContainer}>
+ <TouchableWithoutFeedback onPress={navigateToProfile}>
+ <Text style={styles.actorName}>{notification_title}</Text>
+ </TouchableWithoutFeedback>
+ <TouchableWithoutFeedback
+ style={styles.textContainerStyles}
+ onPress={onNotificationTap}>
+ <Text>
+ <Text style={styles.verbageStyles}>{verbage} </Text>
+ <Text style={styles.timeStampStyles}>
+ {getTimeInShorthand(timestamp)}
+ </Text>
+ </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>
+ )}
+ {/* Message button when user accepts friend request */}
+ {notification_type === 'FRD_ACPT' && (
+ <View style={styles.buttonsContainer}>
+ <MessageButton
+ userXId={id}
+ isBlocked={false}
+ friendship_status={'friends'}
+ externalStyles={{
+ container: {
+ width: normalize(63),
+ height: normalize(21),
+ marginTop: '7%',
+ },
+ buttonTitle: {
+ fontSize: normalize(11),
+ lineHeight: normalize(13.13),
+ letterSpacing: normalize(0.5),
+ fontWeight: '700',
+ textAlign: 'center',
+ },
+ }}
+ solid
+ />
+ </View>
+ )}
+ {/* Moment Image Preview */}
+ {(notification_type === 'CMT' ||
+ notification_type === 'MOM_3+' ||
+ notification_type === 'MOM_TAG' ||
+ notification_type === 'MOM_FRIEND') &&
+ notification_object && (
+ <TouchableWithoutFeedback
+ style={styles.moment}
+ onPress={onNotificationTap}>
+ <Image style={styles.imageFlex} source={{uri: momentURI}} />
+ </TouchableWithoutFeedback>
)}
- {/* Moment Image Preview */}
- {(notification_type === 'CMT' ||
- notification_type === 'MOM_3+' ||
- notification_type === 'MOM_TAG' ||
- notification_type === 'MOM_FRIEND') &&
- notification_object && (
- <TouchableWithoutFeedback
- style={styles.moment}
- onPress={onNotificationTap}>
- <Image style={styles.imageFlex} source={{uri: momentURI}} />
- </TouchableWithoutFeedback>
- )}
- </>
</View>
);