MCPcopy Create free account
hub / github.com/async-labs/async / loadActiveDiscussionsStoreMethod

Method loadActiveDiscussionsStoreMethod

app/lib/store/User.ts:371–401  ·  view source on GitHub ↗
({ teamId }: { teamId: string })

Source from the content-addressed store, hash-verified

369 // if user is Team Leader, show all Discussions inside Team
370 // review
371 public async loadActiveDiscussionsStoreMethod({ teamId }: { teamId: string }) {
372 if (this.store.isServer || this.isLoadingDiscussions) {
373 return;
374 }
375
376 this.isLoadingDiscussions = true;
377
378 try {
379 const { discussions = [] } = await getActiveDiscussionListApiMethod({ teamId });
380
381 runInAction(() => {
382 this.activeDiscussionsForUser.clear();
383
384 discussions.forEach((d) => {
385 const disObj = this.activeDiscussionsForUser.find((obj) => obj.discussionId === d._id);
386 if (disObj) {
387 disObj.changeLocalCacheStoreMethod(d);
388 } else {
389 const newD = new Discussion({ team: this.currentTeam, store: this.store, ...d });
390 if (newD.discussionMemberIds.includes(this._id)) {
391 this.activeDiscussionsForUser.push(newD);
392 }
393 }
394 });
395 });
396 } finally {
397 runInAction(() => {
398 this.isLoadingDiscussions = false;
399 });
400 }
401 }
402
403 public async loadArchivedDiscussionsStoreMethod({ teamId }: { teamId: string }) {
404 if (this.store.isServer || this.isLoadingDiscussions) {

Callers 3

DiscussionListClass · 0.80
componentDidMountMethod · 0.80

Tested by

no test coverage detected