1
0
Эх сурвалжийг харах

Update Notification component, add at (@) symbol for remote profiles and local urls for remote posts and profiles

Daniel Supernault 4 жил өмнө
parent
commit
aafd6a21a5

+ 26 - 10
resources/assets/js/components/NotificationCard.vue

@@ -20,51 +20,51 @@
 					<div class="media-body font-weight-light small">
 					<div class="media-body font-weight-light small">
 						<div v-if="n.type == 'favourite'">
 						<div v-if="n.type == 'favourite'">
 							<p class="my-0">
 							<p class="my-0">
-								<a :href="n.account.url" class="font-weight-bold text-dark word-break" :title="n.account.username">{{truncate(n.account.username)}}</a> liked your
+								<a :href="getProfileUrl(n.account)" class="font-weight-bold text-dark word-break" :title="n.account.username">{{n.account.local == false ? '@':''}}{{truncate(n.account.username)}}</a> liked your
 								<span v-if="n.status.hasOwnProperty('media_attachments')">
 								<span v-if="n.status.hasOwnProperty('media_attachments')">
-									<a class="font-weight-bold" v-bind:href="n.status.url" :id="'fvn-' + n.id">post</a>.
+									<a class="font-weight-bold" v-bind:href="getPostUrl(n.status)" :id="'fvn-' + n.id">post</a>.
 									<b-popover :target="'fvn-' + n.id" title="" triggers="hover" placement="top" boundary="window">
 									<b-popover :target="'fvn-' + n.id" title="" triggers="hover" placement="top" boundary="window">
 										<img :src="notificationPreview(n)" width="100px" height="100px" style="object-fit: cover;">
 										<img :src="notificationPreview(n)" width="100px" height="100px" style="object-fit: cover;">
 									</b-popover>
 									</b-popover>
 								</span>
 								</span>
 								<span v-else>
 								<span v-else>
-									<a class="font-weight-bold" v-bind:href="n.status.url">post</a>.
+									<a class="font-weight-bold" v-bind:href="getPostUrl(n.status)">post</a>.
 								</span>
 								</span>
 							</p>
 							</p>
 						</div>
 						</div>
 						<div v-else-if="n.type == 'comment'">
 						<div v-else-if="n.type == 'comment'">
 							<p class="my-0">
 							<p class="my-0">
-								<a :href="n.account.url" class="font-weight-bold text-dark word-break" :title="n.account.username">{{truncate(n.account.username)}}</a> commented on your <a class="font-weight-bold" v-bind:href="n.status.url">post</a>.
+								<a :href="getProfileUrl(n.account)" class="font-weight-bold text-dark word-break" :title="n.account.username">{{n.account.local == false ? '@':''}}{{truncate(n.account.username)}}</a> commented on your <a class="font-weight-bold" v-bind:href="getPostUrl(n.status)">post</a>.
 							</p>
 							</p>
 						</div>
 						</div>
 						<div v-else-if="n.type == 'mention'">
 						<div v-else-if="n.type == 'mention'">
 							<p class="my-0">
 							<p class="my-0">
-								<a :href="n.account.url" class="font-weight-bold text-dark word-break" :title="n.account.username">{{truncate(n.account.username)}}</a> <a class="font-weight-bold" v-bind:href="mentionUrl(n.status)">mentioned</a> you.
+								<a :href="getProfileUrl(n.account)" class="font-weight-bold text-dark word-break" :title="n.account.username">{{n.account.local == false ? '@':''}}{{truncate(n.account.username)}}</a> <a class="font-weight-bold" v-bind:href="mentionUrl(n.status)">mentioned</a> you.
 							</p>
 							</p>
 						</div>
 						</div>
 						<div v-else-if="n.type == 'follow'">
 						<div v-else-if="n.type == 'follow'">
 							<p class="my-0">
 							<p class="my-0">
-								<a :href="n.account.url" class="font-weight-bold text-dark word-break" :title="n.account.username">{{truncate(n.account.username)}}</a> followed you.
+								<a :href="getProfileUrl(n.account)" class="font-weight-bold text-dark word-break" :title="n.account.username">{{n.account.local == false ? '@':''}}{{truncate(n.account.username)}}</a> followed you.
 							</p>
 							</p>
 						</div>
 						</div>
 						<div v-else-if="n.type == 'share'">
 						<div v-else-if="n.type == 'share'">
 							<p class="my-0">
 							<p class="my-0">
-								<a :href="n.account.url" class="font-weight-bold text-dark word-break" :title="n.account.username">{{truncate(n.account.username)}}</a> shared your <a class="font-weight-bold" v-bind:href="n.status.url">post</a>.
+								<a :href="getProfileUrl(n.account)" class="font-weight-bold text-dark word-break" :title="n.account.username">{{n.account.local == false ? '@':''}}{{truncate(n.account.username)}}</a> shared your <a class="font-weight-bold" v-bind:href="getPostUrl(n.status)">post</a>.
 							</p>
 							</p>
 						</div>
 						</div>
 						<div v-else-if="n.type == 'modlog'">
 						<div v-else-if="n.type == 'modlog'">
 							<p class="my-0">
 							<p class="my-0">
-								<a :href="n.account.url" class="font-weight-bold text-dark word-break" :title="n.account.username">{{truncate(n.account.username)}}</a> updated a <a class="font-weight-bold" v-bind:href="n.modlog.url">modlog</a>.
+								<a :href="getProfileUrl(n.account)" class="font-weight-bold text-dark word-break" :title="n.account.username">{{truncate(n.account.username)}}</a> updated a <a class="font-weight-bold" v-bind:href="n.modlog.url">modlog</a>.
 							</p>
 							</p>
 						</div>
 						</div>
 						<div v-else-if="n.type == 'tagged'">
 						<div v-else-if="n.type == 'tagged'">
 							<p class="my-0">
 							<p class="my-0">
-								<a :href="n.account.url" class="font-weight-bold text-dark word-break" :title="n.account.username">{{truncate(n.account.username)}}</a> tagged you in a <a class="font-weight-bold" v-bind:href="n.tagged.post_url">post</a>.
+								<a :href="getProfileUrl(n.account)" class="font-weight-bold text-dark word-break" :title="n.account.username">{{n.account.local == false ? '@':''}}{{truncate(n.account.username)}}</a> tagged you in a <a class="font-weight-bold" v-bind:href="n.tagged.post_url">post</a>.
 							</p>
 							</p>
 						</div>
 						</div>
 						<div v-else-if="n.type == 'direct'">
 						<div v-else-if="n.type == 'direct'">
 							<p class="my-0">
 							<p class="my-0">
-								<a :href="n.account.url" class="font-weight-bold text-dark word-break" :title="n.account.username">{{truncate(n.account.username)}}</a> sent a <a class="font-weight-bold" v-bind:href="'/account/direct/t/'+n.account.id">dm</a>.
+								<a :href="getProfileUrl(n.account)" class="font-weight-bold text-dark word-break" :title="n.account.username">{{n.account.local == false ? '@':''}}{{truncate(n.account.username)}}</a> sent a <a class="font-weight-bold" v-bind:href="'/account/direct/t/'+n.account.id">dm</a>.
 							</p>
 							</p>
 						</div>
 						</div>
 						<div v-else>
 						<div v-else>
@@ -256,6 +256,22 @@
 					return '/storage/no-preview.png';
 					return '/storage/no-preview.png';
 				}
 				}
 				return n.status.media_attachments[0].preview_url;
 				return n.status.media_attachments[0].preview_url;
+			},
+
+			getProfileUrl(account) {
+				if(account.local == true) {
+					return account.url;
+				}
+
+				return '/i/web/profile/_/' + account.id;
+			},
+
+			getPostUrl(status) {
+				if(status.local == true) {
+					return status.url;
+				}
+
+				return '/i/web/post/_/' + status.account.id + '/' + status.id;
 			}
 			}
 		}
 		}
 	}
 	}