aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-10-24 01:26:37 +0300
committerGravatar Vitaly Takmazov2018-10-24 01:26:37 +0300
commit6b8bc1b2f098d42fa821a67887e85260483c81f3 (patch)
tree3434e9fea45c4a9583deb9b7947dc10190576d2c
parent6af07890fb74f38385dd148cb9107048e4347c1f (diff)
scripts: stupid users cache
-rw-r--r--juick-server/src/main/assets/scripts.js32
1 files changed, 19 insertions, 13 deletions
diff --git a/juick-server/src/main/assets/scripts.js b/juick-server/src/main/assets/scripts.js
index 51314b0b..add5105b 100644
--- a/juick-server/src/main/assets/scripts.js
+++ b/juick-server/src/main/assets/scripts.js
@@ -603,20 +603,26 @@ function addTag(tag) {
return false;
}
+var users = {};
+
function fetchUserUri(dataUri, callback) {
- let data = new FormData();
- data.append('uri', dataUri);
- fetch('/u/', {
- cache: 'force-cache',
- method: 'POST',
- body: data
- }).then(handleErrors)
- .then(response => {
- return response.json();
- })
- .then(json => {
- callback(json);
- });
+ if (users[dataUri]) {
+ callback(users[dataUri]);
+ } else {
+ let data = new FormData();
+ data.append('uri', dataUri);
+ fetch('/u/', {
+ method: 'POST',
+ body: data
+ }).then(handleErrors)
+ .then(response => {
+ return response.json();
+ })
+ .then(json => {
+ users[dataUri] = json;
+ callback(json);
+ });
+ }
}
/******************************************************************************/