Browse Source

Add current time as query string to end of picture url to force browsers to reload the new image

sbkwgh 7 years ago
parent
commit
5488a3af95
1 changed files with 5 additions and 3 deletions
  1. 5 3
      routes/user.js

+ 5 - 3
routes/user.js

@@ -246,13 +246,15 @@ router.post('/:username/picture', upload.single('picture'), async (req, res) =>
 			if(!picture) {
 				picture = await ProfilePicture.create(pictureObj)
 				await picture.setUser(user)
-				await user.update({
-					picture: '/api/v1/user/' + req.session.username + '/picture'
-				})
 			} else {
 				await picture.update(pictureObj)
 			}
 
+			//Add random query to end to force browser to reload background images
+			await user.update({
+				picture: '/api/v1/user/' + req.session.username + '/picture?rand=' + Date.now()
+			})
+
 			res.json(user.toJSON())
 		}
 	} catch (e) {