Skip to content

Commit 8475c9a

Browse files
Show People who right swiped you, Fix None photo on ViewProfile
Workaround based on message to implement people who right swiped you, may need improvement using firestore collection or MySQL table in future, currently bloom filter is fulfilling their requirement for fast matching use case
1 parent 68478ef commit 8475c9a

File tree

7 files changed

+146
-96
lines changed

7 files changed

+146
-96
lines changed

Backend/app.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,20 @@ def get_chats_after_last_cached():
10691069
# }
10701070
# or "DateTime": "Tue, 26 Oct 2021 13:10:38 GMT"
10711071

1072+
1073+
@ app.route("/delete_last_msg", methods=['POST'])
1074+
@jwt_required()
1075+
def delete_last_msg():
1076+
if request.method == "POST":
1077+
pid = int(request.json['pid'])
1078+
id = get_jwt_identity()
1079+
last_msg = Messages.query.filter((Messages.Sender_ID == pid) & (
1080+
Messages.Receiver_ID == id)).order_by(Messages.timestamp.desc()).first()
1081+
db.session.delete(last_msg)
1082+
db.session.commit()
1083+
return "Deleted", 200
1084+
1085+
10721086
# ==============================================================================
10731087

10741088

Frontend/App.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const App = () => {
7979
const [user, setUser] = React.useState({});
8080
const [axiosInst, setaxiosInstance] = React.useState({});
8181
const [isConnected, setIsConnected] = React.useState(true);
82+
const [verticalProfiles, setVerticalProfiles] = React.useState([]);
8283

8384
const BASE_ADDRESS = 'https://campusspace.herokuapp.com';
8485
// Platform.OS === 'android' ? Android_Local_ADDRESS : IOS_Local_ADDRESS;
@@ -209,6 +210,8 @@ const App = () => {
209210
// NOTE pass common Networking instance
210211
axiosInstance: axiosInst.axiosInstance,
211212
setaxiosInstance,
213+
verticalProfiles,
214+
setVerticalProfiles,
212215
// vProfilesInterval,
213216
// setVProfilesInterval,
214217
}}>

Frontend/components/Chat.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ function Chat(props) {
4545
allChats,
4646
setAllChats,
4747
// verticalProfiles,
48-
setVerticalProfiles,
48+
// setVerticalProfiles,
4949
// getData,
5050
// storeData,
5151
} = React.useContext(ChatContext);
5252

5353
const {colors} = useTheme();
5454
const route = useRoute();
5555

56-
const {user, axiosInstance} = useAuth();
56+
const {user, axiosInstance, setVerticalProfiles} = useAuth();
5757

5858
const [chatText, setChatText] = React.useState('');
5959
// const [isLoading, setIsLoading] = React.useState(false);

Frontend/components/Discover.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ function Discover({route}) {
132132
}
133133
} else {
134134
console.log('Yet to Match');
135+
try {
136+
const msg = await axiosInstance.post('/message', {
137+
Receiver_ID: cards[index].id,
138+
text: `Right Swiped ${cards[index].id}`,
139+
});
140+
} catch (err) {
141+
console.log(err);
142+
}
135143
}
136144
setIndex(index + 1);
137145
};

Frontend/components/MessageSection.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const MessageSectionStack = createNativeStackNavigator();
1414

1515
function MessageSection() {
1616
const [allChats, setAllChats] = React.useState({});
17-
const [verticalProfiles, setVerticalProfiles] = React.useState([]);
17+
// const [verticalProfiles, setVerticalProfiles] = React.useState([]);
1818
// const MMKV = new MMKVStorage.Loader().initialize();
1919

2020
// const removeItem = key => {
@@ -72,14 +72,26 @@ function MessageSection() {
7272
// removeItem,
7373
allChats,
7474
setAllChats,
75-
verticalProfiles,
76-
setVerticalProfiles,
75+
// verticalProfiles,
76+
// setVerticalProfiles,
7777
}}>
7878
<MessageSectionStack.Navigator>
7979
<MessageSectionStack.Screen
8080
name="Messages"
8181
component={Messages}
8282
options={{headerShown: false}}></MessageSectionStack.Screen>
83+
<MessageSectionStack.Screen
84+
name="ViewProfileRightSwipedU"
85+
component={ViewProfile}
86+
options={({route}) => ({
87+
headerTitle: () => (
88+
<LogoTitle
89+
user={route?.params?.card_user}
90+
Routename={route.name}
91+
/>
92+
),
93+
headerRight: () => <IconButton icon="dots-horizontal" />,
94+
})}></MessageSectionStack.Screen>
8395
<MessageSectionStack.Screen
8496
name="Chat"
8597
component={Chat}

Frontend/components/Messages.js

Lines changed: 41 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import {ChatContext} from './ChatContext';
1717
import {defaultProfilePic} from '../staticStore';
1818

1919
function Messages() {
20-
const {user, axiosInstance} = useAuth();
20+
const {user, axiosInstance, verticalProfiles, setVerticalProfiles} =
21+
useAuth();
2122
// let {vProfilesInterval, setVProfilesInterval} = useAuth();
2223
const {vProfilesInterval, setVProfilesInterval} = React.useState();
2324
const [refreshing, setRefreshing] = React.useState(false);
@@ -29,8 +30,8 @@ function Messages() {
2930
const {
3031
allChats,
3132
setAllChats,
32-
verticalProfiles,
33-
setVerticalProfiles,
33+
// verticalProfiles,
34+
// setVerticalProfiles,
3435
// storeData,
3536
// getData,
3637
// removeItem,
@@ -93,6 +94,8 @@ function Messages() {
9394
// if (res.length > 0 && vProfilesInterval._idleTimeout !== -1) {
9495
if (res.length > 0) {
9596
await setVerticalProfiles(prevVProfiles => {
97+
let vPs = [],
98+
hPs = [];
9699
res.map(profile => {
97100
if (
98101
prevVProfiles.some(
@@ -105,8 +108,17 @@ function Messages() {
105108
) {
106109
profile.newmsgs = 0;
107110
}
111+
if (
112+
profile.text === `Right Swiped ${user.id}` &&
113+
profile.Sender_ID !== user.id
114+
) {
115+
hPs.push(profile);
116+
} else {
117+
vPs.push(profile);
118+
}
108119
});
109-
return res;
120+
setHorizontalProfiles(hPs);
121+
return vPs;
110122
});
111123
}
112124
// console.log('Res: ', res);
@@ -123,24 +135,6 @@ function Messages() {
123135
React.useEffect(() => {
124136
// setIsLoading(true);
125137

126-
// async function getProfiles() {
127-
// try {
128-
// Loop to fetch 8 horizontal profiles
129-
// for (let i = 0; i < 8; i++) {
130-
// const response = await fetch(
131-
// 'https://randomuser.me/api/?results=1&inc=name,picture,email,location,phone,cell,dob,login,registered,id,nat&noinfo',
132-
// );
133-
// const data = await response.json();
134-
// setHorizontalProfiles(horizontalProfiles => [
135-
// ...horizontalProfiles,
136-
// data.results[0],
137-
// ]);
138-
// }
139-
140-
// console.log(horizontalProfiles);
141-
// }
142-
// getProfiles();
143-
144138
// console.log('Before append: ', allChats);
145139
const init = async () => {
146140
await getMessageProfiles();
@@ -195,7 +189,7 @@ function Messages() {
195189
}}>
196190
{console.log('Messages Rerender')}
197191
<FocusAwareStatusBar barStyle={'dark-content'} backgroundColor={'#fff'} />
198-
{/* <Text
192+
<Text
199193
style={{
200194
padding: 10,
201195
color: colors.primary,
@@ -221,48 +215,18 @@ function Messages() {
221215
justifyContent: 'center',
222216
}}
223217
onPress={() => {
224-
card1 = {
225-
id: 1,
226-
name: 'Tanya Agrawal',
227-
email: 'abc@viit.ac.in',
228-
personalEmail: '[email protected]',
229-
bio: 'Common man',
230-
photo:
231-
'https://media-exp1.licdn.com/dms/image/C5103AQFKbyGxKxMYGA/profile-displayphoto-shrink_200_200/0/1539165110959?e=1638403200&v=beta&t=c93WpMen-FJ1jheRQ2DAhVzHWU06ocZHHvjp1BH2jSM',
232-
info: 'BTech | CS | A1',
233-
year: '2023',
234-
division: 'A',
235-
batch: 'A1',
236-
branch: 'Information Technology',
237-
headline:
238-
'Student at VIIT | Passionate about NodeJS, Angular and iOS',
239-
requirements:
240-
'Looking for a python developer who is comfortable with numpy and pandas. Need someone who is capable of extracting insights from the given data. Knowledge of iOS development or Web Development is a plus.',
241-
skills: [
242-
'Web Development',
243-
'iOS App Development',
244-
'NodeJS',
245-
'Angular',
246-
'Swift',
247-
'Objective-C',
248-
],
249-
links: {
250-
// https://www.linkedin.com/in/
251-
linkedin: 'rohini-dutta-b9a8a817b',
252-
// https://www.github.com/
253-
github: 'siddheshkothadi',
254-
// https://twitter.com/
255-
twitter: 'siddheshkothadi',
256-
},
257-
languages: ['Marathi', 'English', 'Hindi'],
258-
};
259218
navigation.navigate('ViewProfileRightSwipedU', {
260-
card_user: card1,
219+
card_user: {id: profile.pid, name: profile.Name},
220+
swiperRef: -2,
221+
setHorizontalProfiles: setHorizontalProfiles,
261222
});
262223
}}>
263224
<Image
264225
source={{
265-
uri: profile.picture.large,
226+
uri:
227+
profile.Image_URL && profile.Image_URL !== 'None'
228+
? profile.Image_URL
229+
: defaultProfilePic,
266230
}}
267231
style={{
268232
width: 64,
@@ -271,32 +235,32 @@ function Messages() {
271235
borderRadius: 50,
272236
}}
273237
/>
274-
{index < 2 && (
275-
<View
276-
style={{
277-
position: 'absolute',
278-
right: 3,
279-
top: 50,
280-
backgroundColor: colors.success,
281-
padding: 0,
282-
borderWidth: 2,
283-
borderColor: '#fff',
284-
borderRadius: 10,
285-
height: 12,
286-
width: 12,
287-
}}></View>
288-
)}
238+
{/* {index < 2 && ( */}
239+
<View
240+
style={{
241+
position: 'absolute',
242+
right: 3,
243+
top: 50,
244+
backgroundColor: colors.success,
245+
padding: 0,
246+
borderWidth: 2,
247+
borderColor: '#fff',
248+
borderRadius: 10,
249+
height: 12,
250+
width: 12,
251+
}}></View>
252+
{/* )} */}
289253
<Text
290254
style={{
291255
textAlign: 'center',
292256
fontSize: 11,
293257
color: colors.textLightBlack,
294258
}}>
295-
{profile.name.first}
259+
{profile.Name}
296260
</Text>
297261
</TouchableOpacity>
298262
))}
299-
</ScrollView> */}
263+
</ScrollView>
300264

301265
<View
302266
style={{

0 commit comments

Comments
 (0)