(data)
| 613 | } |
| 614 | |
| 615 | public async createOrUpdateDiscussionStoreMethod(data): Promise<Discussion> { |
| 616 | const { discussion, initialComments } = await createOrUpdateDiscussionApiMethod({ |
| 617 | socketId: (this.store.socket && this.store.socket.id) || null, |
| 618 | ...data, |
| 619 | }); |
| 620 | |
| 621 | if (data.id) { |
| 622 | const newObj = new Discussion({ |
| 623 | ...discussion, |
| 624 | initialComments, |
| 625 | team: this.currentTeam, |
| 626 | store: this.store, |
| 627 | }); |
| 628 | |
| 629 | runInAction(() => { |
| 630 | if ( |
| 631 | newObj.discussionMemberIds.includes(this.store.currentUser._id) && |
| 632 | newObj.discussionLeaderId === this.store.currentUser._id |
| 633 | ) { |
| 634 | const filteredDiscussions = this.activeDiscussionsForUser.filter( |
| 635 | (d) => d.discussionId !== data.id, |
| 636 | ); |
| 637 | this.activeDiscussionsForUser.replace(filteredDiscussions); |
| 638 | this.activeDiscussionsForUser.push(newObj); |
| 639 | } |
| 640 | }); |
| 641 | |
| 642 | return newObj; |
| 643 | } else { |
| 644 | return new Promise<Discussion>((resolve) => { |
| 645 | runInAction(() => { |
| 646 | const obj = this.addDiscussionToLocalCacheStoreMethod(discussion, initialComments); |
| 647 | resolve(obj); |
| 648 | }); |
| 649 | }); |
| 650 | } |
| 651 | } |
| 652 | |
| 653 | public addDiscussionToLocalCacheStoreMethod(data, initialComments): Discussion { |
| 654 | const obj = new Discussion({ |
no test coverage detected