From ddaf0797be48876eade913d2b9b5c1357ce6bc5e Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Tue, 2 Feb 2021 16:17:47 -0500 Subject: fixed thumbnail reuse bug, added gradient --- src/components/notifications/Notification.tsx | 82 ++++++++++++++++----------- src/services/CommonService.ts | 2 +- 2 files changed, 51 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/components/notifications/Notification.tsx b/src/components/notifications/Notification.tsx index 28a5d912..4258e288 100644 --- a/src/components/notifications/Notification.tsx +++ b/src/components/notifications/Notification.tsx @@ -53,7 +53,6 @@ const Notification: React.FC = (props) => { const [avatar, setAvatar] = useState(undefined); const [momentURI, setMomentURI] = useState(undefined); - const backgroundColor = unread ? '#DCF1F1' : 'rgba(0,0,0,0)'; const [onTapLoadProfile, setOnTapLoadProfile] = useState(false); useEffect(() => { @@ -61,6 +60,8 @@ const Notification: React.FC = (props) => { const response = await loadImageFromURL(thumbnail_url); if (response) { setAvatar(response); + } else { + setAvatar(''); } })(); }, []); @@ -81,9 +82,17 @@ const Notification: React.FC = (props) => { const response = await loadMomentThumbnail(moment_id); if (mounted && response) { setMomentURI(response); + } else { + // if not set to empty, it will re-use the previous notification's state + setMomentURI(''); } }; - if (notification_type === 'CMT' && notification_object) { + if ( + (notification_type === 'CMT' || + notification_type === 'MOM_3+' || + notification_type === 'MOM_FRIEND') && + notification_object + ) { loadMomentImage( notification_object.moment_id ? notification_object.moment_id @@ -200,41 +209,50 @@ const Notification: React.FC = (props) => { dispatch(loadUserNotifications()); }; - return ( - - - - ( + + + + + + + {first_name} {last_name} + + {verbage} + + {notification_type === 'FRD_REQ' && ( + + - - - {first_name} {last_name} - - {verbage} - - {notification_type === 'FRD_REQ' && ( - - - - )} - {notification_type === 'CMT' && notification_object && ( + )} + {(notification_type === 'CMT' || + notification_type === 'MOM_3+' || + notification_type === 'MOM_FRIEND') && + notification_object && ( )} - + + ); + + return unread ? ( + + {renderContent()} + ) : ( + renderContent() ); }; diff --git a/src/services/CommonService.ts b/src/services/CommonService.ts index 4f9fb47a..dfbbf70e 100644 --- a/src/services/CommonService.ts +++ b/src/services/CommonService.ts @@ -6,7 +6,7 @@ export const loadImageFromURL = async (url: string) => { return undefined; } const response = await RNFetchBlob.config({ - fileCache: true, + fileCache: false, appendExt: 'jpg', }).fetch('GET', url); const status = response.info().status; -- cgit v1.2.3-70-g09d2