|
|
@ -109,6 +109,7 @@ export class FeedService extends BaseService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public postsAvailable = new BehaviorSubject<boolean>(true);
|
|
|
|
public postsAvailable = new BehaviorSubject<boolean>(true);
|
|
|
|
|
|
|
|
public posting = new BehaviorSubject<boolean>(false);
|
|
|
|
public posts: BehaviorSubject<Post[]> = new BehaviorSubject([]);
|
|
|
|
public posts: BehaviorSubject<Post[]> = new BehaviorSubject([]);
|
|
|
|
private activePostList: Sort = Sort.NEW;
|
|
|
|
private activePostList: Sort = Sort.NEW;
|
|
|
|
private offset = 0;
|
|
|
|
private offset = 0;
|
|
|
@ -186,6 +187,7 @@ export class FeedService extends BaseService {
|
|
|
|
* @param file - a file that is being uploaded with the post
|
|
|
|
* @param file - a file that is being uploaded with the post
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private createPostRequest(body: { variables: any; query: string }, file?: File) {
|
|
|
|
private createPostRequest(body: { variables: any; query: string }, file?: File) {
|
|
|
|
|
|
|
|
this.posting.next(true);
|
|
|
|
if (file) {
|
|
|
|
if (file) {
|
|
|
|
return this.postGraphql(body, null, 0)
|
|
|
|
return this.postGraphql(body, null, 0)
|
|
|
|
.pipe(tap(response => {
|
|
|
|
.pipe(tap(response => {
|
|
|
@ -197,8 +199,10 @@ export class FeedService extends BaseService {
|
|
|
|
post.mediaType = result.fileName.endsWith('.png') ? 'IMAGE' : 'VIDEO';
|
|
|
|
post.mediaType = result.fileName.endsWith('.png') ? 'IMAGE' : 'VIDEO';
|
|
|
|
updatedPosts.unshift(post);
|
|
|
|
updatedPosts.unshift(post);
|
|
|
|
this.posts.next(updatedPosts);
|
|
|
|
this.posts.next(updatedPosts);
|
|
|
|
|
|
|
|
this.posting.next(false);
|
|
|
|
}, error => {
|
|
|
|
}, error => {
|
|
|
|
console.error(error);
|
|
|
|
console.error(error);
|
|
|
|
|
|
|
|
this.posting.next(false);
|
|
|
|
this.deletePost(post.id);
|
|
|
|
this.deletePost(post.id);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -206,6 +210,7 @@ export class FeedService extends BaseService {
|
|
|
|
} else if (!file) {
|
|
|
|
} else if (!file) {
|
|
|
|
return this.postGraphql(body, null, 0)
|
|
|
|
return this.postGraphql(body, null, 0)
|
|
|
|
.pipe(tap(response => {
|
|
|
|
.pipe(tap(response => {
|
|
|
|
|
|
|
|
this.posting.next(false);
|
|
|
|
const updatedPosts = this.posts.getValue();
|
|
|
|
const updatedPosts = this.posts.getValue();
|
|
|
|
if (this.activePostList === Sort.NEW) {
|
|
|
|
if (this.activePostList === Sort.NEW) {
|
|
|
|
const post = this.constructPost(response);
|
|
|
|
const post = this.constructPost(response);
|
|
|
|