Skip to content

Commit 180ebe3

Browse files
Vedant Royvedantroy
authored andcommitted
Keep user info
1 parent 422d6a1 commit 180ebe3

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/server.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,16 @@ app.post(
161161
async (request, response) => {
162162
const { body, datastoreKey: key, event } = request;
163163
const [lat, long] = body.location;
164-
const { name } = body;
164+
const { name, address } = body;
165165
event.users = event.users || {};
166166
const userInfo = event.users[request.session.userID] || {};
167-
event.users[request.session.userID] = { ...userInfo, name, lat, long };
167+
event.users[request.session.userID] = {
168+
...userInfo,
169+
name,
170+
lat,
171+
long,
172+
address,
173+
};
168174
datastore
169175
// Datastore attaches a "symbol" (https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Symbol)
170176
// to any entities returned from a query. We don't want to store this attached metadata back into the database

static/absolute/js/searchPage.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ window.onload = function () {
5050
headers: window.HEADER_CONTENT_TYPE_JSON,
5151
body: JSON.stringify({
5252
name,
53+
address,
5354
location: [lat, long],
5455
}),
5556
});
@@ -66,8 +67,6 @@ window.onload = function () {
6667
alert("error posting to api");
6768
return;
6869
}
69-
nameInput.value = "";
70-
addressInput.value = "";
7170
});
7271

7372
document.getElementById("participants-btn").addEventListener("click", () => {
@@ -111,6 +110,13 @@ socket.on("refresh", () => {
111110
async function refreshUI() {
112111
const eventId = getEventId();
113112

113+
fetch(`/api/${eventId}/me`)
114+
.then((response) => response.json())
115+
.then(({ data: { name, address } = {} }) => {
116+
document.getElementById("name-input").value = name ? name : "";
117+
document.getElementById("address-input").value = address ? address : "";
118+
});
119+
114120
let failure = false;
115121
let map = null;
116122
const LACoords = [34.052235, -118.243683];

0 commit comments

Comments
 (0)