diff --git a/web/src/api/user.ts b/web/src/api/user.ts index 38c5c33dc..d244327c5 100644 --- a/web/src/api/user.ts +++ b/web/src/api/user.ts @@ -1,6 +1,6 @@ import { DefaultClient, PBResponse } from "./client"; -let me: User; +let _globalMePromise: Promise; export class User { pk: number; @@ -15,10 +15,10 @@ export class User { } static me(): Promise { - if (me) { - return Promise.resolve(me); + if (!_globalMePromise) { + _globalMePromise = DefaultClient.fetch(["core", "users", "me"]); } - return DefaultClient.fetch(["core", "users", "me"]).then(u => me = u); + return _globalMePromise; } static count(): Promise {