Quellcode durchsuchen

Update Timeline component, cascade relationship state change

Daniel Supernault vor 3 Jahren
Ursprung
Commit
f4bd5672b1
1 geänderte Dateien mit 26 neuen und 2 gelöschten Zeilen
  1. 26 2
      resources/assets/js/components/Timeline.vue

+ 26 - 2
resources/assets/js/components/Timeline.vue

@@ -12,7 +12,7 @@
 					<div style="margin-top:-2px;">
 					<div style="margin-top:-2px;">
 						<story-component v-if="config.features.stories" :scope="scope"></story-component>
 						<story-component v-if="config.features.stories" :scope="scope"></story-component>
 					</div>
 					</div>
-					<div>
+					<div class="pt-4">
 						<div v-if="loading" class="text-center" style="padding-top:10px;">
 						<div v-if="loading" class="text-center" style="padding-top:10px;">
 							<div class="spinner-border" role="status">
 							<div class="spinner-border" role="status">
 								<span class="sr-only">Loading...</span>
 								<span class="sr-only">Loading...</span>
@@ -106,6 +106,8 @@
 								size="small"
 								size="small"
 								v-on:status-delete="deleteStatus"
 								v-on:status-delete="deleteStatus"
 								v-on:comment-focus="commentFocus"
 								v-on:comment-focus="commentFocus"
+								v-on:followed="followedAccount"
+								v-on:unfollowed="unfollowedAccount"
 							/>
 							/>
 						</div>
 						</div>
 
 
@@ -1067,7 +1069,29 @@
 				this.feed = this.feed.filter(s => {
 				this.feed = this.feed.filter(s => {
 					return s.id != status;
 					return s.id != status;
 				});
 				});
-			}
+			},
+
+			followedAccount(id) {
+				this.feed = this.feed.map(s => {
+					if(s.account.id == id) {
+						if(s.hasOwnProperty('relationship') && s.relationship.following == false) {
+							s.relationship.following = true;
+						}
+					}
+					return s;
+				});
+			},
+
+			unfollowedAccount(id) {
+				this.feed = this.feed.map(s => {
+					if(s.account.id == id) {
+						if(s.hasOwnProperty('relationship') && s.relationship.following == true) {
+							s.relationship.following = false;
+						}
+					}
+					return s;
+				});
+			},
 		},
 		},
 
 
 		beforeDestroy () {
 		beforeDestroy () {