attempt to produce thumbnail url from marketId (works only partially), move model population code to model

This commit is contained in:
Alexander Ivash 2018-05-05 19:32:50 +03:00
parent 566074c86f
commit 57568d120e
2 changed files with 21 additions and 65 deletions

View file

@ -33,19 +33,7 @@ Rectangle {
emitSendToScript({'method' : getAvatarsMethod}); emitSendToScript({'method' : getAvatarsMethod});
} else if(message.method === getAvatarsMethod) { } else if(message.method === getAvatarsMethod) {
var getAvatarsReply = message.reply; var getAvatarsReply = message.reply;
var i = 0; allAvatars.populate(getAvatarsReply.bookmarks);
for(var avatarName in getAvatarsReply.bookmarks) {
var avatarEntry = {
'name' : avatarName,
'url' : Qt.resolvedUrl(allAvatars.urls[i++ % allAvatars.urls.length]),
'wearables' : getAvatarsReply.bookmarks[avatarName].avatarEntites ? getAvatarsReply.bookmarks[avatarName].avatarEntites : [],
'entry' : getAvatarsReply.bookmarks[avatarName],
'getMoreAvatars' : false
};
allAvatars.append(avatarEntry);
}
var currentAvatar = getAvatarsReply.currentAvatar; var currentAvatar = getAvatarsReply.currentAvatar;
console.debug('currentAvatar: ', JSON.stringify(currentAvatar, null, '\t')); console.debug('currentAvatar: ', JSON.stringify(currentAvatar, null, '\t'));

View file

@ -3,58 +3,26 @@ import QtQuick 2.9
ListModel { ListModel {
id: model id: model
property var urls: [ function populate(bookmarks) {
'../../images/samples/hifi-mp-e76946cc-c272-4adf-9bb6-02cde0a4b57d.png', for(var avatarName in bookmarks) {
'../../images/samples/hifi-mp-e76946cc-c272-4adf-9bb6-02cde0a4b57d-1.png', var splittedUrl = bookmarks[avatarName].avatarUrl.split('/');
'../../images/samples/hifi-mp-e76946cc-c272-4adf-9bb6-02cde0a4b57d-2.png', var marketId = splittedUrl[splittedUrl.length - 2];
'../../images/samples/hifi-mp-e76946cc-c272-4adf-9bb6-02cde0a4b57d-3.png', var indexOfVSuffix = marketId.indexOf('-v');
'../../images/samples/hifi-mp-e76946cc-c272-4adf-9bb6-02cde0a4b57d-4.png', if(indexOfVSuffix !== -1) {
'../../images/samples/hifi-mp-e76946cc-c272-4adf-9bb6-02cde0a4b57d-5.png', marketId = marketId.substring(0, indexOfVSuffix);
'../../images/samples/hifi-mp-e76946cc-c272-4adf-9bb6-02cde0a4b57d-5.png', }
] var avatarThumbnailUrl = "https://hifi-metaverse.s3-us-west-1.amazonaws.com/marketplace/previews/%marketId%/medium/hifi-mp-%marketId%.jpg"
.split('%marketId%').join(marketId);
/* var avatarEntry = {
ListElement { 'name' : avatarName,
url: '../../images/samples/hifi-mp-e76946cc-c272-4adf-9bb6-02cde0a4b57d.png' 'url' : avatarThumbnailUrl,
name: 'Woody' 'wearables' : bookmarks[avatarName].avatarEntites ? bookmarks[avatarName].avatarEntites : [],
wearables: '' 'entry' : bookmarks[avatarName],
favorite: false 'getMoreAvatars' : false
};
append(avatarEntry);
}
} }
ListElement {
url: '../../images/samples/hifi-mp-e76946cc-c272-4adf-9bb6-02cde0a4b57d-1.png'
name: 'Damien'
wearables: ''
favorite: false
}
ListElement {
url: '../../images/samples/hifi-mp-e76946cc-c272-4adf-9bb6-02cde0a4b57d-2.png'
name: 'Lexi'
wearables: ''
favorite: false
}
ListElement {
url: '../../images/samples/hifi-mp-e76946cc-c272-4adf-9bb6-02cde0a4b57d-3.png'
name: 'Judie'
wearables: ''
favorite: true
}
ListElement {
url: '../../images/samples/hifi-mp-e76946cc-c272-4adf-9bb6-02cde0a4b57d-4.png'
name: 'Alex'
wearables: ''
favorite: true
}
ListElement {
url: '../../images/samples/hifi-mp-e76946cc-c272-4adf-9bb6-02cde0a4b57d-5.png'
name: 'Matthew'
wearables: ''
favorite: true
}
ListElement {
url: '../../images/samples/hifi-mp-e76946cc-c272-4adf-9bb6-02cde0a4b57d-5.png'
name: 'Ogre'
wearables: ''
favorite: true
}
*/
} }