Skip to content

Commit

Permalink
Fix: fix publishing posts relating to task issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Ifycode committed Nov 14, 2024
1 parent 4e3deef commit f13e59d
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions apps/web-mzima-client/src/app/post/post-head/post-head.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ import { TranslateService } from '@ngx-translate/core';
import { BreakpointService, EventBusService, EventType, SessionService } from '@services';
import { BaseComponent } from '../../base.component';
import { ShareModalComponent } from '../../shared/components';
import {
PostPropertiesInterface,
PostResult,
PostsService,
PostStatus,
postHelpers,
} from '@mzima-client/sdk';
import { PostResult, PostsService, PostStatus, postHelpers } from '@mzima-client/sdk';
import { ConfirmModalService } from '../../core/services/confirm-modal.service';

@Component({
Expand All @@ -22,7 +16,7 @@ import { ConfirmModalService } from '../../core/services/confirm-modal.service';
})
export class PostHeadComponent extends BaseComponent implements OnInit {
PostStatus = PostStatus;
@Input() public post: PostResult | PostPropertiesInterface;
@Input() public post: PostResult;
@Input() public editable: boolean;
@Input() public feedView: boolean;
@Input() public deleteable: boolean;
Expand Down Expand Up @@ -83,13 +77,23 @@ export class PostHeadComponent extends BaseComponent implements OnInit {
}

publish() {
if (postHelpers.isAllRequiredCompleted(this.post)) {
this.postsService.updateStatus(this.post.id, PostStatus.Published).subscribe((res) => {
this.post = res.result;
this.statusChanged.emit();
});
const publishPostCode = (post: PostResult) => {
if (postHelpers.isAllRequiredCompleted(post)) {
this.postsService.updateStatus(this.post.id, PostStatus.Published).subscribe((res) => {
this.post = res.result;
this.statusChanged.emit();
});
} else {
this.showMessage(this.translate.instant('notify.post.unfinished_post_task'), 'error', 5000);
}
};

if (this.post.post_content) {
publishPostCode(this.post);
} else {
this.showMessage(this.translate.instant('notify.post.unfinished_post_task'), 'error', 5000);
this.postsService.getById(this.post.id).subscribe((post) => {
publishPostCode(post);
});
}
}

Expand Down

0 comments on commit f13e59d

Please sign in to comment.