|
|
@ -6,6 +6,7 @@ import {DatasharingService} from '../../services/datasharing.service';
|
|
|
|
import {ActivityService} from 'src/app/services/activity/activity.service';
|
|
|
|
import {ActivityService} from 'src/app/services/activity/activity.service';
|
|
|
|
import {User} from 'src/app/models/user';
|
|
|
|
import {User} from 'src/app/models/user';
|
|
|
|
import {IErrorResponse} from '../../models/interfaces/IErrorResponse';
|
|
|
|
import {IErrorResponse} from '../../models/interfaces/IErrorResponse';
|
|
|
|
|
|
|
|
import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
|
selector: 'home-feed',
|
|
|
|
selector: 'home-feed',
|
|
|
@ -15,6 +16,12 @@ import {IErrorResponse} from '../../models/interfaces/IErrorResponse';
|
|
|
|
export class FeedComponent implements OnInit {
|
|
|
|
export class FeedComponent implements OnInit {
|
|
|
|
loadingNew = true;
|
|
|
|
loadingNew = true;
|
|
|
|
loadingMostLiked = true;
|
|
|
|
loadingMostLiked = true;
|
|
|
|
|
|
|
|
// file upload variables
|
|
|
|
|
|
|
|
public uploading = false;
|
|
|
|
|
|
|
|
public profilePictureUrl: BehaviorSubject<string | null>;
|
|
|
|
|
|
|
|
private file;
|
|
|
|
|
|
|
|
private fileType;
|
|
|
|
|
|
|
|
public localFileUrl;
|
|
|
|
|
|
|
|
|
|
|
|
checked = false; // if the "I protected the environment."-box is checked
|
|
|
|
checked = false; // if the "I protected the environment."-box is checked
|
|
|
|
view = 'new';
|
|
|
|
view = 'new';
|
|
|
@ -27,7 +34,7 @@ export class FeedComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
|
|
loggedIn = false;
|
|
|
|
loggedIn = false;
|
|
|
|
user: User;
|
|
|
|
user: User;
|
|
|
|
errorOccurred: boolean;
|
|
|
|
errorOccurred = false;
|
|
|
|
|
|
|
|
|
|
|
|
private errorMessage: string;
|
|
|
|
private errorMessage: string;
|
|
|
|
|
|
|
|
|
|
|
@ -89,6 +96,22 @@ export class FeedComponent implements OnInit {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onFileInputChange(event) {
|
|
|
|
|
|
|
|
this.errorOccurred = false;
|
|
|
|
|
|
|
|
this.errorMessage = '';
|
|
|
|
|
|
|
|
this.file = event.target.files[0];
|
|
|
|
|
|
|
|
if (this.file.type.includes('video')) {
|
|
|
|
|
|
|
|
this.fileType = 'video';
|
|
|
|
|
|
|
|
} else if (this.file.type.includes('image')) {
|
|
|
|
|
|
|
|
this.fileType = 'image';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const reader = new FileReader();
|
|
|
|
|
|
|
|
reader.onload = (e: any) => {
|
|
|
|
|
|
|
|
this.localFileUrl = e.target.result;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
reader.readAsDataURL(this.file);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Fetches the next posts when scrolled
|
|
|
|
* Fetches the next posts when scrolled
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|