aboutsummaryrefslogtreecommitdiff
path: root/src/components/notifications/Notification.tsx
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2020-12-30 21:01:49 -0500
committerIvan Chen <ivan@tagg.id>2021-01-15 20:18:02 -0500
commitde4e8228d85d2b91e3152e1000ce1f1b644bba4e (patch)
tree1252db0f375338a609f9d800d379c016c7183125 /src/components/notifications/Notification.tsx
parent1803da7388902db45ad37fbac509604ae632bdb5 (diff)
finished
Diffstat (limited to 'src/components/notifications/Notification.tsx')
-rw-r--r--src/components/notifications/Notification.tsx51
1 files changed, 19 insertions, 32 deletions
diff --git a/src/components/notifications/Notification.tsx b/src/components/notifications/Notification.tsx
index 184e3f27..2bcee89e 100644
--- a/src/components/notifications/Notification.tsx
+++ b/src/components/notifications/Notification.tsx
@@ -1,22 +1,9 @@
import {useNavigation} from '@react-navigation/native';
import React, {useEffect, useState} from 'react';
-import {
- ActivityIndicatorBase,
- Alert,
- Image,
- StyleSheet,
- Text,
- View,
-} from 'react-native';
+import {Image, StyleSheet, Text, View} from 'react-native';
import {TouchableWithoutFeedback} from 'react-native-gesture-handler';
import {useDispatch, useSelector, useStore} from 'react-redux';
-import {MomentCommentsScreen} from '../../screens';
-import {loadAvatar} from '../../services';
-import {
- EMPTY_MOMENTS_LIST,
- EMPTY_MOMENT_CATEGORIES,
-} from '../../store/initialStates';
-import {userSocialsReducer} from '../../store/reducers';
+import {loadAvatar, loadMomentThumbnail} from '../../services';
import {RootState} from '../../store/rootReducer';
import {NotificationType, ScreenType} from '../../types';
import {
@@ -70,20 +57,21 @@ const Notification: React.FC<NotificationProps> = (props) => {
};
}, [id]);
- // TODO: this should be moment thumbnail, waiting for that to complete
- // useEffect(() => {
- // let mounted = true;
- // const loadMomentImage = async (user_id: string) => {
- // const response = await loadAvatar(user_id, true);
- // if (mounted) {
- // setMomentURI(response);
- // }
- // };
- // loadMomentImage(id);
- // return () => {
- // mounted = false;
- // };
- // }, [id, notification_object]);
+ useEffect(() => {
+ let mounted = true;
+ const loadMomentImage = async (moment_id: string) => {
+ const response = await loadMomentThumbnail(moment_id);
+ if (mounted) {
+ setMomentURI(response);
+ }
+ };
+ if (notification_type === 'CMT' && notification_object) {
+ loadMomentImage(notification_object.moment_id);
+ return () => {
+ mounted = false;
+ };
+ }
+ }, [id, notification_object, notification_type]);
const onNotificationTap = async () => {
switch (notification_type) {
@@ -144,13 +132,12 @@ const Notification: React.FC<NotificationProps> = (props) => {
</Text>
<Text>{verbage}</Text>
</View>
- {/* TODO: Still WIP */}
- {/* {notification_type === 'CMT' && notification_object && (
+ {notification_type === 'CMT' && notification_object && (
<Image
style={styles.moment}
source={{uri: momentURI, cache: 'only-if-cached'}}
/>
- )} */}
+ )}
</TouchableWithoutFeedback>
);
};