Add query param to automatically upload avatar
E.g. to automatically use Matrix avatar when embedded as a Matrix widget
This commit is contained in:
parent
d3cf7f0f22
commit
3a8e730a1a
27
app/index.js
27
app/index.js
|
@ -800,6 +800,33 @@ window.onload = function () {
|
||||||
if (queryParams.password) {
|
if (queryParams.password) {
|
||||||
ui.connectDialog.password(queryParams.password)
|
ui.connectDialog.password(queryParams.password)
|
||||||
}
|
}
|
||||||
|
if (queryParams.avatarurl) {
|
||||||
|
// Download the avatar and upload it to the mumble server when connected
|
||||||
|
let url = queryParams.avatarurl
|
||||||
|
console.log('Fetching avatar from', url)
|
||||||
|
let req = new window.XMLHttpRequest()
|
||||||
|
req.open('GET', url, true)
|
||||||
|
req.responseType = 'arraybuffer'
|
||||||
|
req.onload = () => {
|
||||||
|
let upload = (avatar) => {
|
||||||
|
if (req.response) {
|
||||||
|
console.log('Uploading user avatar to server')
|
||||||
|
ui.client.setSelfTexture(req.response)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// On any future connections
|
||||||
|
ui.thisUser.subscribe((thisUser) => {
|
||||||
|
if (thisUser) {
|
||||||
|
upload()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// And the current one (if already connected)
|
||||||
|
if (ui.thisUser()) {
|
||||||
|
upload()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
req.send()
|
||||||
|
}
|
||||||
ui.connectDialog.joinOnly(useJoinDialog)
|
ui.connectDialog.joinOnly(useJoinDialog)
|
||||||
ko.applyBindings(ui)
|
ko.applyBindings(ui)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue