Add loading animation to post media

master
Max 5 years ago
parent 2250492ccc
commit 8ddb1eac87

@ -92,7 +92,6 @@ export class FeedComponent implements OnInit {
} else if (postElement) {
this.posting = true;
this.feedService.createPost(postElement.value, this.file).subscribe((result) => {
console.log('response in component');
this.posting = false;
postElement.value = '';
this.textInputValue = '';
@ -104,7 +103,6 @@ export class FeedComponent implements OnInit {
this.showNew();
}
}, (error: IErrorResponse) => {
console.log('an error occured in component');
console.log(error);
this.posting = false;
this.errorOccurred = true;

@ -22,9 +22,10 @@
</mat-card-subtitle>
</mat-card-header>
<mat-card-content>
<div class="postMedia">
<img *ngIf="post.mediaType === 'IMAGE'" [src]="post.mediaUrl" alt="post image"/>
<video *ngIf="post.mediaType === 'VIDEO'" controls>
<mat-spinner *ngIf="post.mediaLoading" style="margin:0 auto; margin-top: 2em;" diameter="50"></mat-spinner>
<div class="postMedia" [hidden]="post.mediaLoading">
<img *ngIf="post.mediaType === 'IMAGE'" [src]="post.mediaUrl" (load)="onLoad(this.post)" alt="post image"/>
<video *ngIf="post.mediaType === 'VIDEO'" (load)="onLoad(this.post)" controls>
<source [src]="post.mediaUrl" type="video/webm">
</video>
</div>

@ -49,6 +49,11 @@ export class PostlistComponent implements OnInit {
});
}
onLoad(post: Post) {
console.log('loaded' + post.content);
post.mediaLoading = false;
}
public showUserProfile(post: any) {
this.router.navigate(['profile/' + post.author.id]);
}

@ -13,6 +13,7 @@ export class Post {
deletable: boolean;
author: Author;
activity: Activity;
mediaLoading: boolean;
mediaUrl: string;
mediaType: 'VIDEO' | 'IMAGE';
@ -42,6 +43,7 @@ export class Post {
if (media) {
this.mediaUrl = environment.greenvironmentUrl + media.url;
this.mediaType = media.type;
this.mediaLoading = true;
}
}
}

@ -209,7 +209,7 @@ export class FeedService extends BaseService {
const updatedPosts = this.posts.getValue();
if (this.activePostList === Sort.NEW) {
const post = this.constructPost(response);
updatedPosts.unshift(post);
updatedPosts.unshift(post);
this.posts.next(updatedPosts);
}
}));

Loading…
Cancel
Save