1
- import { LRUCache } from 'lru-cache'
2
1
import type { mastodon } from 'masto'
2
+ import { LRUCache } from 'lru-cache'
3
3
4
4
const cache = new LRUCache < string , any > ( {
5
5
max : 1000 ,
@@ -25,11 +25,10 @@ export function fetchStatus(id: string, force = false): Promise<mastodon.v1.Stat
25
25
if ( cached && ! force )
26
26
return Promise . resolve ( cached )
27
27
28
- const promise = useMastoClient ( ) . v1 . statuses . $select ( id ) . fetch ( )
29
- . then ( ( status ) => {
30
- cacheStatus ( status )
31
- return status
32
- } )
28
+ const promise = useMastoClient ( ) . v1 . statuses . $select ( id ) . fetch ( ) . then ( ( status ) => {
29
+ cacheStatus ( status )
30
+ return status
31
+ } )
33
32
cache . set ( key , promise )
34
33
return promise
35
34
}
@@ -46,14 +45,13 @@ export function fetchAccountById(id?: string | null): Promise<mastodon.v1.Accoun
46
45
return Promise . resolve ( cached )
47
46
48
47
const domain = getInstanceDomainFromServer ( server )
49
- const promise = useMastoClient ( ) . v1 . accounts . $select ( id ) . fetch ( )
50
- . then ( ( r ) => {
51
- if ( r . acct && ! r . acct . includes ( '@' ) && domain )
52
- r . acct = `${ r . acct } @${ domain } `
48
+ const promise = useMastoClient ( ) . v1 . accounts . $select ( id ) . fetch ( ) . then ( ( r ) => {
49
+ if ( r . acct && ! r . acct . includes ( '@' ) && domain )
50
+ r . acct = `${ r . acct } @${ domain } `
53
51
54
- cacheAccount ( r , server , true )
55
- return r
56
- } )
52
+ cacheAccount ( r , server , true )
53
+ return r
54
+ } )
57
55
cache . set ( key , promise )
58
56
return promise
59
57
}
@@ -101,11 +99,10 @@ export function fetchTag(tagName: string, force = false): Promise<mastodon.v1.Ta
101
99
if ( cached && ! force )
102
100
return Promise . resolve ( cached )
103
101
104
- const promise = useMastoClient ( ) . v1 . tags . $select ( tagName ) . fetch ( )
105
- . then ( ( tag ) => {
106
- cacheTag ( tag )
107
- return tag
108
- } )
102
+ const promise = useMastoClient ( ) . v1 . tags . $select ( tagName ) . fetch ( ) . then ( ( tag ) => {
103
+ cacheTag ( tag )
104
+ return tag
105
+ } )
109
106
cache . set ( key , promise )
110
107
return promise
111
108
}
0 commit comments