diff options
author | Vitaly Takmazov | 2022-10-28 13:49:18 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-13 10:37:58 +0300 |
commit | d30ed659de70a2cd833a18c02005b5c9a3b84bd8 (patch) | |
tree | 7f4182a3da38bd8fad5acbf1c4eba9f8cee1aa51 /vnext/src/api/index.js | |
parent | 8aecfadb13f8fc6053470d80de2acd2b3f160f57 (diff) |
Basic profile caching
Diffstat (limited to 'vnext/src/api/index.js')
-rw-r--r-- | vnext/src/api/index.js | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/vnext/src/api/index.js b/vnext/src/api/index.js index f88695f2..aa0ddc6e 100644 --- a/vnext/src/api/index.js +++ b/vnext/src/api/index.js @@ -213,6 +213,8 @@ export function markReadTracker(msg, visitor) { return `${apiBaseUrl}/api/thread/mark_read/${msg.mid}-${msg.rid || 0}.gif?hash=${visitor.hash}`; } +let profileCache = {}; + /** * Fetch user profile * @@ -220,10 +222,17 @@ export function markReadTracker(msg, visitor) { */ export function fetchUserUri(profileUrl) { return new Promise((resolve, reject) => { - client.get(profileUrl, { - headers: { - 'Accept': 'application/ld+json' - } - }).then(response => resolve(response)).catch(reject); + if (profileCache[profileUrl]) { + resolve(profileCache[profileUrl]); + } else { + client.get(profileUrl, { + headers: { + 'Accept': 'application/ld+json' + } + }).then(response => { + profileCache[profileUrl] = response.data; + resolve(response.data); + }).catch(reject); + } }); } |