Skip to content

Commit 3093170

Browse files
ux changes
1 parent e99003b commit 3093170

File tree

1 file changed

+34
-27
lines changed

1 file changed

+34
-27
lines changed

src/components/StudyBuddy.vue

+34-27
Original file line numberDiff line numberDiff line change
@@ -50,35 +50,42 @@ export default {
5050
methods: {
5151
showInstagramAlert() {
5252
alert("This feature will be rolled out soon. Stay tuned.");
53+
},
54+
fetchUserData() {
55+
if (navigator.geolocation) {
56+
navigator.geolocation.getCurrentPosition(async (position) => {
57+
this.latitude = position.coords.latitude;
58+
this.longitude = position.coords.longitude;
59+
this.loading = true;
60+
61+
try {
62+
const url = `${this.$globalData.backendUrl}/studybuddy/`;
63+
const response = await axios.post(url, {
64+
token2: this.token2,
65+
latitude: this.latitude,
66+
longitude: this.longitude
67+
});
68+
69+
this.users = response.data;
70+
} catch (error) {
71+
alert(error.response?.data?.error || 'An error occurred');
72+
} finally {
73+
this.loading = false;
74+
}
75+
}, (error) => {
76+
alert('Geolocation not supported or permission denied');
77+
});
78+
} else {
79+
alert('Geolocation is not supported by this browser.');
80+
}
5381
}
5482
},
55-
async mounted() {
56-
57-
if (navigator.geolocation) {
58-
navigator.geolocation.getCurrentPosition(async (position) => {
59-
this.latitude = position.coords.latitude;
60-
this.longitude = position.coords.longitude;
61-
this.loading = true;
62-
63-
try {
64-
const url = `${this.$globalData.backendUrl}/studybuddy/`;
65-
const response = await axios.post(url, {
66-
token2: this.token2,
67-
latitude: this.latitude,
68-
longitude: this.longitude
69-
});
70-
71-
this.users = response.data;
72-
} catch (error) {
73-
alert(error.response?.data?.error || 'An error occurred');
74-
} finally {
75-
this.loading = false;
76-
}
77-
}, (error) => {
78-
alert('Geolocation not supported or permission denied');
79-
});
80-
} else {
81-
alert('Geolocation is not supported by this browser.');
83+
mounted() {
84+
if (this.token2) {
85+
this.fetchUserData();
86+
}
87+
else{
88+
alert("Login with IITM Google Account & Give Location Access")
8289
}
8390
}
8491
};

0 commit comments

Comments
 (0)