mirror of
https://github.com/ItsVipra/ProToots
synced 2025-02-16 20:48:23 +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";
|
import { normaliseAccountName } from "./protootshelpers";
|
||||||
|
|
||||||
const cacheMaxAge = 24 * 60 * 60 * 1000; // time after which cached pronouns should be checked again: 24h
|
const cacheMaxAge = 24 * 60 * 60 * 1000; // time after which cached pronouns should be checked again: 24h
|
||||||
|
let conversationsCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches pronouns associated with account name.
|
* Fetches pronouns associated with account name.
|
||||||
|
@ -138,6 +139,7 @@ async function fetchAccount(accountID) {
|
||||||
* DOCS: https://docs.joinmastodon.org/methods/conversations/#response
|
* DOCS: https://docs.joinmastodon.org/methods/conversations/#response
|
||||||
*/
|
*/
|
||||||
async function fetchConversations() {
|
async function fetchConversations() {
|
||||||
|
if (conversationsCache) return conversationsCache;
|
||||||
//the api wants status IDs, not conversation IDs
|
//the api wants status IDs, not conversation IDs
|
||||||
//as a result we can only get pronouns for the first 40 conversations max
|
//as a result we can only get pronouns for the first 40 conversations max
|
||||||
//most of these should be in cache anyways
|
//most of these should be in cache anyways
|
||||||
|
@ -151,6 +153,7 @@ async function fetchConversations() {
|
||||||
);
|
);
|
||||||
|
|
||||||
const conversations = await response.json();
|
const conversations = await response.json();
|
||||||
|
conversationsCache = conversations;
|
||||||
|
|
||||||
return conversations;
|
return conversations;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue