{"version":3,"sources":["https://lively-kernel.org/lively4/lively4-jsx/src/client/reactive/components/rewritten/conduit/src/stores/profileStore.js"],"names":["agent","ProfileStore","loadProfile","username","profile","follow","unfollow"],"mappings":"AAAA;;;;;;;;;;;;;;;;;AAEOA,W;;;;;;;;;;;;;;;;;;;;;;;AAEP,YAAMC,YAAN,CAAmB;;AAEjBC,oBAAYC,QAAZ,EAAsB;AAAA;;AACpB,+CAAwB,IAAxB;AACA,4QAAkBA,QAAlB,cACQ,CAAC,EAAEC,OAAF,EAAD;AAAA;AAAiB,mIAAeA,OAAf;AAAjB,WADR,gBAEW;AACP,wDAAwB,KAAxB;AADO,WAFX;AAID;;AAEDC,iBAAS;AACP,cAAI,+BAAgB,uBAAC,IAAD,0BAApB,EAA6C;AAC3C,iEAAyB,IAAzB;AACA,+LAAqB,IAArB,uCACS;AACL,0EAAyB,KAAzB;AADK,aADT;AAGD;AACF;;AAEDC,mBAAW;AACT,cAAI,qDAAgB,IAAhB,0BAAJ,EAA4C;AAC1C,iEAAyB,KAAzB;AACA,iMAAuB,IAAvB,uCACS;AACL,0EAAyB,IAAzB;AADK,aADT;AAGD;AACF;AA1BgB;;;;;;;;;;;;;;;;;;yBA6BJ,iGAAIL,YAAJ,G","file":"profileStore.js","sourcesContent":["'enable aexpr';\n\nimport agent from 'src/client/reactive/components/rewritten/conduit/src/agent.js';\n\nclass ProfileStore {\n\n  loadProfile(username) {\n    this.isLoadingProfile = true;\n    agent.Profile.get(username)\n      .then(({ profile }) => this.profile = profile)\n      .finally(() => \n        this.isLoadingProfile = false);\n  }\n\n  follow() {\n    if (this.profile && !this.profile.following) {\n      this.profile.following = true;\n      agent.Profile.follow(this.profile.username)\n        .catch(() => \n          this.profile.following = false);\n    }\n  }\n\n  unfollow() {\n    if (this.profile && this.profile.following) {\n      this.profile.following = false;\n      agent.Profile.unfollow(this.profile.username)\n        .catch(() =>\n          this.profile.following = true);\n    }\n  }\n}\n\nexport default new ProfileStore();"]}