mirror of
https://github.com/ItsVipra/ProToots
synced 2024-11-22 11:33:03 +00:00
cache conversations
This commit is contained in:
parent
b294648ac7
commit
6529aea860
1 changed files with 3 additions and 0 deletions
|
@ -3,6 +3,7 @@ import { cachePronouns, getPronouns } from "./caching";
|
|||
import { normaliseAccountName } from "./protootshelpers";
|
||||
|
||||
const cacheMaxAge = 24 * 60 * 60 * 1000; // time after which cached pronouns should be checked again: 24h
|
||||
let conversationsCache;
|
||||
|
||||
/**
|
||||
* Fetches pronouns associated with account name.
|
||||
|
@ -138,6 +139,7 @@ async function fetchAccount(accountID) {
|
|||
* DOCS: https://docs.joinmastodon.org/methods/conversations/#response
|
||||
*/
|
||||
async function fetchConversations() {
|
||||
if (conversationsCache) return conversationsCache;
|
||||
//the api wants status IDs, not conversation IDs
|
||||
//as a result we can only get pronouns for the first 40 conversations max
|
||||
//most of these should be in cache anyways
|
||||
|
@ -151,6 +153,7 @@ async function fetchConversations() {
|
|||
);
|
||||
|
||||
const conversations = await response.json();
|
||||
conversationsCache = conversations;
|
||||
|
||||
return conversations;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue