Skip to content

Commit

Permalink
Merge branch 'master' into #2788
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz authored Nov 16, 2023
2 parents 6fef48f + e5eb4ef commit 0edc037
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/extension/background-script/connectors/alby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default class Alby implements Connector {
private config: Config;
private _client: Client | undefined;
private _authUser: auth.OAuth2User | undefined;
private _cache = new Map<string, object>();

constructor(account: Account, config: Config) {
this.account = account;
Expand Down Expand Up @@ -116,16 +117,27 @@ export default class Alby implements Connector {
async getInfo(): Promise<
GetInfoResponse<WebLNNode & GetAccountInformationResponse>
> {
const cacheKey = "getInfo";
const cacheValue = this._cache.get(cacheKey) as GetInfoResponse<
WebLNNode & GetAccountInformationResponse
>;
if (cacheValue) {
return cacheValue;
}

try {
const info = await this._request((client) =>
client.accountInformation({})
);
return {
const returnValue = {
data: {
...info,
alias: "🐝 getalby.com",
},
};
this._cache.set(cacheKey, returnValue);

return returnValue;
} catch (error) {
console.error(error);
throw error;
Expand Down

0 comments on commit 0edc037

Please sign in to comment.