Skip to content

Commit

Permalink
Made remove/add methods in ForumModule async
Browse files Browse the repository at this point in the history
  • Loading branch information
jedrek2504 committed Dec 17, 2023
1 parent bd5c0fa commit 5c4daa4
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/modules/forum/model/ForumModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ export class ForumModule {
this.userManager = UMM.IntermoduleCommons.IntermoduleUserManager;
}

public addPost(user: ForumUser, post: ForumPost): boolean {
this.forumMediator.registerPost(user, post).then((succeeded: boolean) => {
public async addPost(user: ForumUser, post: ForumPost): Promise<boolean> {
try {
const succeeded = await this.forumMediator.registerPost(user, post);
if (succeeded) {
this.postList.addPost(post);
const notification = new UserNotification();
Expand All @@ -32,17 +33,24 @@ export class ForumModule {
this.notificationManager.notifyUser(user.getId(), notification);
return true;
}
})
return false;
return false;
} catch (error) {
console.error('Error in addPost:', error);
return false;
}
}

public removePost(user: ForumUser, post: ForumPost): boolean {
this.forumMediator.unregisterPost(user, post).then((succeeded: boolean) => {
public async removePost(user: ForumUser, post: ForumPost): Promise<boolean> {
try {
const succeeded = await this.forumMediator.unregisterPost(user, post);
if (succeeded) {
return this.postList.removePost(post);
}
})
return false;
return false;
} catch (error) {
console.error('Error in removePost:', error);
return false;
}
}

public sendNotification(user: ForumUser, message: string): boolean {
Expand Down

0 comments on commit 5c4daa4

Please sign in to comment.