Ver Fonte

Update Timeline component

Daniel Supernault há 5 anos atrás
pai
commit
58e8ac4d44
1 ficheiros alterados com 22 adições e 61 exclusões
  1. 22 61
      resources/assets/js/components/Timeline.vue

+ 22 - 61
resources/assets/js/components/Timeline.vue

@@ -517,13 +517,6 @@
 		beforeMount() {
 		beforeMount() {
 			this.fetchProfile();
 			this.fetchProfile();
 			this.fetchTimelineApi();
 			this.fetchTimelineApi();
-
-			// if(this.config.announcement.enabled == true) {
-			// 	let msg = $('<div>')
-			// 	.addClass('alert alert-warning mb-0 rounded-0 text-center font-weight-bold')
-			// 	.html(this.config.announcement.message);
-			// 	$('body').prepend(msg);
-			// }
 		},
 		},
 
 
 		mounted() {
 		mounted() {
@@ -602,7 +595,7 @@
 				axios.get(apiUrl, {
 				axios.get(apiUrl, {
 					params: {
 					params: {
 						max_id: this.max_id,
 						max_id: this.max_id,
-						limit: 6
+						limit: 4
 					}
 					}
 				}).then(res => {
 				}).then(res => {
 					let data = res.data;
 					let data = res.data;
@@ -611,15 +604,20 @@
 					this.ids = ids;
 					this.ids = ids;
 					this.min_id = Math.max(...ids);
 					this.min_id = Math.max(...ids);
 					this.max_id = Math.min(...ids);
 					this.max_id = Math.min(...ids);
-					$('.timeline .pagination').removeClass('d-none');
 					this.loading = false;
 					this.loading = false;
-					if(this.feed.length == 6) {
-						this.fetchHashtagPosts();
+					$('.timeline .pagination').removeClass('d-none');
+					if(this.feed.length == 4) {
 						this.fetchTimelineApi();
 						this.fetchTimelineApi();
-					} else {
+					} 
+					if(this.hashtagPosts.length == 0) {
 						this.fetchHashtagPosts();
 						this.fetchHashtagPosts();
 					}
 					}
 				}).catch(err => {
 				}).catch(err => {
+					swal(
+						'Oops, something went wrong',
+						'Please reload the page.',
+						'error'
+					);
 				});
 				});
 			},
 			},
 
 
@@ -645,7 +643,7 @@
 				axios.get(apiUrl, {
 				axios.get(apiUrl, {
 					params: {
 					params: {
 						max_id: this.max_id,
 						max_id: this.max_id,
-						limit: 9
+						limit: 6
 					},
 					},
 				}).then(res => {
 				}).then(res => {
 					if (res.data.length && this.loading == false) {
 					if (res.data.length && this.loading == false) {
@@ -671,32 +669,6 @@
 				});
 				});
 			},
 			},
 
 
-			loadMore(event) {
-				let homeTimeline = '/api/pixelfed/v1/timelines/home';
-				let localTimeline = '/api/pixelfed/v1/timelines/public';
-				let apiUrl = this.scope == 'home' ? homeTimeline : localTimeline;
-				event.target.innerText = 'Loading...';
-				axios.get(apiUrl, {
-					params: {
-						page: this.page,
-					},
-				}).then(res => {
-					if (res.data.length && this.loading == false) {
-						let data = res.data;
-						let ids = data.map(status => status.id);
-						this.min_id = Math.min(...ids);
-						if(this.page == 1) {
-							this.max_id = Math.max(...ids);
-						}
-						this.feed.push(...data);
-						this.page += 1;
-						this.loading = false;
-						event.target.innerText = 'Load more posts';
-					} else {
-					}
-				});
-			},
-
 			reportUrl(status) {
 			reportUrl(status) {
 				let type = status.in_reply_to ? 'comment' : 'post';
 				let type = status.in_reply_to ? 'comment' : 'post';
 				let id = status.id;
 				let id = status.id;
@@ -752,27 +724,11 @@
 				return ts.toDateString() + ' ' + ts.toLocaleTimeString();
 				return ts.toDateString() + ' ' + ts.toLocaleTimeString();
 			},
 			},
 
 
-			editUrl(status) {
-				return status.url + '/edit';
-			},
-
 			redirect(url) {
 			redirect(url) {
 				window.location.href = url;
 				window.location.href = url;
 				return;
 				return;
 			},
 			},
 
 
-			replyUrl(status) {
-				let username = this.profile.username;
-				let id = status.account.id == this.profile.id ? status.id : status.in_reply_to_id;
-				return '/p/' + username + '/' + id;
-			},
-
-			mentionUrl(status) {
-				let username = status.account.username;
-				let id = status.id;
-				return '/p/' + username + '/' + id;
-			},
-
 			statusOwner(status) {
 			statusOwner(status) {
 				let sid = status.account.id;
 				let sid = status.account.id;
 				let uid = this.profile.id;
 				let uid = this.profile.id;
@@ -1089,6 +1045,8 @@
 			},
 			},
 
 
 			expRec() {
 			expRec() {
+				return;
+
 				if(this.config.ab.rec == false) {
 				if(this.config.ab.rec == false) {
 					return;
 					return;
 				}
 				}
@@ -1099,6 +1057,8 @@
 			},
 			},
 
 
 			expRecFollow(id, index) {
 			expRecFollow(id, index) {
+				return;
+
 				if(this.config.ab.rec == false) {
 				if(this.config.ab.rec == false) {
 					return;
 					return;
 				}
 				}
@@ -1170,6 +1130,8 @@
 			}, 
 			}, 
 
 
 			refreshSuggestions() {
 			refreshSuggestions() {
+				return;
+
 				let el = event.target.parentNode;
 				let el = event.target.parentNode;
 				if(el.classList.contains('disabled') == true) {
 				if(el.classList.contains('disabled') == true) {
 					return;
 					return;
@@ -1226,10 +1188,10 @@
 
 
 			ctxMenu(status) {
 			ctxMenu(status) {
 				this.ctxMenuStatus = status;
 				this.ctxMenuStatus = status;
-				let payload = '<div class="pixlfed-media" data-id="'+ this.ctxMenuStatus.id + '"></div><script ';
-				payload += 'src="https://pixelfed.dev/js/embed.js" async><';
-				payload += '/script>';
-				this.ctxEmbedPayload = payload;
+				// let payload = '<div class="pixlfed-media" data-id="'+ this.ctxMenuStatus.id + '"></div><script ';
+				// payload += 'src="https://pixelfed.dev/js/embed.js" async><';
+				// payload += '/script>';
+				// this.ctxEmbedPayload = payload;
 				if(status.account.id == this.profile.id) {
 				if(status.account.id == this.profile.id) {
 					this.$refs.ctxModal.show();
 					this.$refs.ctxModal.show();
 				} else {
 				} else {
@@ -1347,8 +1309,7 @@
 
 
 			hideTips() {
 			hideTips() {
 				this.showTips = false;
 				this.showTips = false;
-				let ls = window.localStorage;
-				ls.setItem('metro-tips', false);
+				window.localStorage.setItem('metro-tips', false);
 			}
 			}
 
 
 		}
 		}