change to username display

This commit is contained in:
booploops 2021-12-04 11:51:31 -08:00
parent e59ae5a9f8
commit cb0ff28b61
2 changed files with 14 additions and 4 deletions

View file

@ -151,7 +151,14 @@
<div class="sidebar-user-icon"> <div class="sidebar-user-icon">
</div> </div>
<div class="sidebar-user-text" id="userName">Not logged in</div> <div class="sidebar-user-text" id="userName">
<template v-if="chrome.userinfo.attributes">
{{ chrome.userinfo.attributes.name }}
</template>
<template v-else>
Sign in
</template>
</div>
</button> </button>
</div> </div>
</div> </div>

View file

@ -119,19 +119,22 @@ const app = new Vue({
details: {} details: {}
}, },
chrome: { chrome: {
artworkReady: false artworkReady: false,
userinfo: {
}
}, },
page: "browse" page: "browse"
}, },
methods: { methods: {
init() { async init() {
let self = this let self = this
this.mk = MusicKit.getInstance() this.mk = MusicKit.getInstance()
this.mk.authorize() this.mk.authorize()
this.$forceUpdate() this.$forceUpdate()
// Set profile name // Set profile name
this.mk.api.personalSocialProfile().then(function(result) {document.getElementById("userName").innerHTML = result.attributes.name}); this.chrome.userinfo = await this.mkapi("personalSocialProfile", false, "")
this.mk.addEventListener(MusicKit.Events.playbackTimeDidChange, (a) => { this.mk.addEventListener(MusicKit.Events.playbackTimeDidChange, (a) => {
self.playerLCD.playbackDuration = (self.mk.currentPlaybackTime) self.playerLCD.playbackDuration = (self.mk.currentPlaybackTime)