Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

W51-2024 development to mobile sync #1506

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ export const enum EventType {
RefreshSurveysCounters = 'REFRESH_SURVEYS_COUNTERS',
StopExportPolling = 'STOP_EXPORT_POLLING',
ExportDone = 'EXPORT_DONE',
StatusChange = 'STATUS_CHANGE',
}

export interface BusEvent<T = any> {
Original file line number Diff line number Diff line change
@@ -72,7 +72,10 @@ export class PostHeadComponent extends BaseComponent implements OnInit {
underReview() {
this.postsService.updateStatus(this.post.id, PostStatus.Draft).subscribe((res) => {
this.post = res.result;
this.statusChanged.emit();
this.eventBusService.next({
type: EventType.StatusChange,
payload: this.post,
});
});
}

@@ -81,7 +84,10 @@ export class PostHeadComponent extends BaseComponent implements OnInit {
if (postHelpers.isAllRequiredCompleted(post)) {
this.postsService.updateStatus(this.post.id, PostStatus.Published).subscribe((res) => {
this.post = res.result;
this.statusChanged.emit();
this.eventBusService.next({
type: EventType.StatusChange,
payload: this.post,
});
});
} else {
this.showMessage(this.translate.instant('notify.post.unfinished_post_task'), 'error', 5000);
@@ -100,7 +106,10 @@ export class PostHeadComponent extends BaseComponent implements OnInit {
archive() {
this.postsService.updateStatus(this.post.id, PostStatus.Archived).subscribe((res) => {
this.post = res.result;
this.statusChanged.emit();
this.eventBusService.next({
type: EventType.StatusChange,
payload: this.post,
});
});
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Component, Input, OnInit } from '@angular/core';
import { PostPropertiesInterface, PostResult } from '@mzima-client/sdk';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { EventBusService, EventType } from '@services';

@UntilDestroy()
@Component({
selector: 'app-post-metadata',
templateUrl: './post-metadata.component.html',
@@ -10,8 +13,18 @@ export class PostMetadataComponent implements OnInit {
@Input() post: PostResult | PostPropertiesInterface;
author: string;

constructor(private eventBusService: EventBusService) {}

ngOnInit(): void {
this.getUsername();
this.eventBusService
.on(EventType.StatusChange)
.pipe(untilDestroyed(this))
.subscribe({
next: (post) => {
if (post.id === this.post.id) this.post = post;
},
});
}

private getUsername(): void {

Unchanged files with check annotations Beta

this.destroy$.complete();
}
ngAfterViewInit(): void {

Check warning on line 68 in apps/mobile-mzima-client/src/app/map/map.page.ts

GitHub Actions / test (16)

Lifecycle interface 'AfterViewInit' should be implemented for method 'ngAfterViewInit'. (https://angular.io/styleguide#style-09-01)

Check warning on line 68 in apps/mobile-mzima-client/src/app/map/map.page.ts

GitHub Actions / test (16)

Lifecycle interface 'AfterViewInit' should be implemented for method 'ngAfterViewInit'. (https://angular.io/styleguide#style-09-01)

Check warning on line 68 in apps/mobile-mzima-client/src/app/map/map.page.ts

GitHub Actions / test (16)

Lifecycle interface 'AfterViewInit' should be implemented for method 'ngAfterViewInit'. (https://angular.io/styleguide#style-09-01)

Check warning on line 68 in apps/mobile-mzima-client/src/app/map/map.page.ts

GitHub Actions / test (16)

Lifecycle interface 'AfterViewInit' should be implemented for method 'ngAfterViewInit'. (https://angular.io/styleguide#style-09-01)

Check warning on line 68 in apps/mobile-mzima-client/src/app/map/map.page.ts

GitHub Actions / test (16)

Lifecycle interface 'AfterViewInit' should be implemented for method 'ngAfterViewInit'. (https://angular.io/styleguide#style-09-01)

Check warning on line 68 in apps/mobile-mzima-client/src/app/map/map.page.ts

GitHub Actions / test (16)

Lifecycle interface 'AfterViewInit' should be implemented for method 'ngAfterViewInit'. (https://angular.io/styleguide#style-09-01)
this.initNetworkListener();
this.initFilterListener();
this.getPost$.pipe(debounceTime(500), takeUntil(this.destroy$)).subscribe({
) {}
//Enabling/disabling delete button by checking if photo was uploaded initially
ngOnInit(): void {

Check warning on line 41 in apps/mobile-mzima-client/src/app/profile/information/components/profile-photo/profile-photo.component.ts

GitHub Actions / test (16)

Lifecycle interface 'OnInit' should be implemented for method 'ngOnInit'. (https://angular.io/styleguide#style-09-01)

Check warning on line 41 in apps/mobile-mzima-client/src/app/profile/information/components/profile-photo/profile-photo.component.ts

GitHub Actions / test (16)

Lifecycle interface 'OnInit' should be implemented for method 'ngOnInit'. (https://angular.io/styleguide#style-09-01)

Check warning on line 41 in apps/mobile-mzima-client/src/app/profile/information/components/profile-photo/profile-photo.component.ts

GitHub Actions / test (16)

Lifecycle interface 'OnInit' should be implemented for method 'ngOnInit'. (https://angular.io/styleguide#style-09-01)

Check warning on line 41 in apps/mobile-mzima-client/src/app/profile/information/components/profile-photo/profile-photo.component.ts

GitHub Actions / test (16)

Lifecycle interface 'OnInit' should be implemented for method 'ngOnInit'. (https://angular.io/styleguide#style-09-01)

Check warning on line 41 in apps/mobile-mzima-client/src/app/profile/information/components/profile-photo/profile-photo.component.ts

GitHub Actions / test (16)

Lifecycle interface 'OnInit' should be implemented for method 'ngOnInit'. (https://angular.io/styleguide#style-09-01)

Check warning on line 41 in apps/mobile-mzima-client/src/app/profile/information/components/profile-photo/profile-photo.component.ts

GitHub Actions / test (16)

Lifecycle interface 'OnInit' should be implemented for method 'ngOnInit'. (https://angular.io/styleguide#style-09-01)
this.sessionService
.getCurrentUserData()
.pipe(
private router: Router,
) {}
ngOnChanges(changes: SimpleChanges) {

Check warning on line 35 in apps/mobile-mzima-client/src/app/shared/components/post-controls/post-controls.component.ts

GitHub Actions / test (16)

Lifecycle interface 'OnChanges' should be implemented for method 'ngOnChanges'. (https://angular.io/styleguide#style-09-01)

Check warning on line 35 in apps/mobile-mzima-client/src/app/shared/components/post-controls/post-controls.component.ts

GitHub Actions / test (16)

Lifecycle interface 'OnChanges' should be implemented for method 'ngOnChanges'. (https://angular.io/styleguide#style-09-01)

Check warning on line 35 in apps/mobile-mzima-client/src/app/shared/components/post-controls/post-controls.component.ts

GitHub Actions / test (16)

Lifecycle interface 'OnChanges' should be implemented for method 'ngOnChanges'. (https://angular.io/styleguide#style-09-01)

Check warning on line 35 in apps/mobile-mzima-client/src/app/shared/components/post-controls/post-controls.component.ts

GitHub Actions / test (16)

Lifecycle interface 'OnChanges' should be implemented for method 'ngOnChanges'. (https://angular.io/styleguide#style-09-01)

Check warning on line 35 in apps/mobile-mzima-client/src/app/shared/components/post-controls/post-controls.component.ts

GitHub Actions / test (16)

Lifecycle interface 'OnChanges' should be implemented for method 'ngOnChanges'. (https://angular.io/styleguide#style-09-01)

Check warning on line 35 in apps/mobile-mzima-client/src/app/shared/components/post-controls/post-controls.component.ts

GitHub Actions / test (16)

Lifecycle interface 'OnChanges' should be implemented for method 'ngOnChanges'. (https://angular.io/styleguide#style-09-01)
if (changes['posts']?.currentValue?.length > 0) {
this.statusOptionsButtons = getPostStatusActions(this.posts[0].status);
}