aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-10-24 09:37:56 +0300
committerGravatar Vitaly Takmazov2018-10-24 09:37:56 +0300
commit37ac91b710a316639eaa2e72bb05c879d7e85199 (patch)
treeae0e8ae786e51296b382e47826f8edde4d055029 /juick-server/src
parentc65346138dff21ac2bb61bfad12f6bcb970c6a1c (diff)
scripts: fetch users cache
Diffstat (limited to 'juick-server/src')
-rw-r--r--juick-server/src/main/assets/scripts.js31
1 files changed, 19 insertions, 12 deletions
diff --git a/juick-server/src/main/assets/scripts.js b/juick-server/src/main/assets/scripts.js
index 6b1176ee..772956b0 100644
--- a/juick-server/src/main/assets/scripts.js
+++ b/juick-server/src/main/assets/scripts.js
@@ -603,19 +603,26 @@ function addTag(tag) {
return false;
}
+var users = {}
+
function fetchUserUri(dataUri, callback) {
- let data = new FormData();
- data.append('uri', dataUri);
- fetch('/u/', {
- 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);
+ });
+ }
}
/******************************************************************************/