Update navbar, add avatar

This commit is contained in:
Daniel Supernault 2020-12-02 21:45:50 -07:00
parent 88fc867c07
commit 19abf1b4dc
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
15 changed files with 46 additions and 1 deletions

View File

@ -200,6 +200,14 @@ window.App.util = {
clipboard: (function(data) {
return navigator.clipboard.writeText(data);
}),
navatar: (function() {
$('#navbarDropdown .far').addClass('d-none');
$('#navbarDropdown img').attr('src',window._sharedData.curUser.avatar)
.removeClass('d-none')
.addClass('rounded-circle border shadow')
.attr('width', 34).attr('height', 34);
})
};

View File

@ -130,6 +130,10 @@ export default {
methods: {
fetchNotifications() {
axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
window._sharedData.curUser = res.data;
window.App.util.navatar();
});
axios.get('/api/pixelfed/v1/notifications', {
params: {
pg: true

View File

@ -191,6 +191,8 @@ export default {
axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
this.currentUser = res.data;
this.owner = this.currentUser.id == this.profileId;
window._sharedData.curUser = res.data;
window.App.util.navatar();
});
}
},

View File

@ -145,6 +145,10 @@ export default {
mounted() {
this.fetchRecentPosts();
this.fetchItems();
axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
window._sharedData.curUser = res.data;
window.App.util.navatar();
});
},
methods: {
addToIds(id) {

View File

@ -246,6 +246,7 @@ export default {
axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
this.profile = res.data;
window._sharedData.curUser = res.data;
window.App.util.navatar();
});
},

View File

@ -433,6 +433,7 @@
axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
this.profile = res.data;
window._sharedData.curUser = res.data;
window.App.util.navatar();
});
},

View File

@ -252,6 +252,10 @@
this.posts = res.data.posts;
this.loaded = true;
});
axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
window._sharedData.curUser = res.data;
window.App.util.navatar();
});
},
fetchCategories() {

View File

@ -123,6 +123,12 @@
},
methods: {
getResults() {
if(this.authenticated) {
axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
window._sharedData.curUser = res.data;
window.App.util.navatar();
});
}
axios.get('/api/v2/discover/tag', {
params: {
hashtag: this.hashtag,

View File

@ -841,6 +841,7 @@ export default {
self.status = response.data.status;
self.user = response.data.user;
window._sharedData.curUser = self.user;
window.App.util.navatar();
self.media = self.status.media_attachments;
self.reactions = response.data.reactions;
self.likes = response.data.likes;

View File

@ -705,6 +705,8 @@
if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == true) {
axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
this.user = res.data;
window._sharedData.curUser = res.data;
window.App.util.navatar();
if(res.data.id == this.profileId || this.relationship.following == true) {
axios.get('/api/stories/v0/exists/' + this.profileId)
.then(res => {

View File

@ -526,6 +526,10 @@ export default {
}).catch(error => {
swal('Oops!', 'An error occured, please try refreshing the page.', 'error');
});
axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
window._sharedData.curUser = res.data;
window.App.util.navatar();
});
},
likesModal() {

View File

@ -220,6 +220,8 @@
fetchProfile() {
axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
this.user = res.data
window._sharedData.curUser = res.data;
window.App.util.navatar();
});
axios.get('/api/pixelfed/v1/accounts/' + this.profileId)
.then(res => {

View File

@ -361,6 +361,10 @@ export default {
let lexer = this.searchLexer();
this.analysis = lexer;
this.fetchSearchResults();
axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
window._sharedData.curUser = res.data;
window.App.util.navatar();
});
},
fetchSearchResults() {

View File

@ -781,6 +781,7 @@
this.modes.mod = true;
}
window._sharedData.curUser = res.data;
window.App.util.navatar();
this.hasStory();
// this.expRec();
}).catch(err => {

View File

@ -31,7 +31,7 @@
@endif
@else
<div class="ml-auto">
<ul class="navbar-nav">
<ul class="navbar-nav align-items-center">
<li class="nav-item px-md-2 d-none d-md-block">
<a class="nav-link font-weight-bold text-muted" href="{{route('discover')}}" title="Discover" data-toggle="tooltip" data-placement="bottom">
<i class="far fa-compass fa-lg"></i>
@ -54,6 +54,7 @@
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="User Menu" data-toggle="tooltip" data-placement="bottom">
<i class="far fa-user fa-lg text-muted"></i>
<span class="sr-only">User Menu</span>
<img class="d-none" src="/storage/avatars/default.png?v=0" class="rounded-circle border shadow" width="34" height="34" onerror="this.onerror=null;this.src='/storage/avatars/default.png?v=0';">
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">