mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 16:46:31 +00:00
fixed bug where duplicate box art icons would appear. This closes #78
This commit is contained in:
parent
7f1caff2e8
commit
4df695bdc9
@ -312,20 +312,23 @@ function showApps() {
|
|||||||
console.log('Moved into showApps, but `api` did not initialize properly! Failing.');
|
console.log('Moved into showApps, but `api` did not initialize properly! Failing.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if game grid is populated, empty it
|
|
||||||
$("#game-grid").empty();
|
$("#game-grid").empty();
|
||||||
|
|
||||||
api.getAppList().then(function (appList) {
|
api.getAppList().then(function (appList) {
|
||||||
|
// if game grid is populated, empty it
|
||||||
appList.forEach(function (app) {
|
appList.forEach(function (app) {
|
||||||
api.getBoxArt(app.id).then(function (resolvedPromise) {
|
api.getBoxArt(app.id).then(function (resolvedPromise) {
|
||||||
// put the box art into the image holder
|
// put the box art into the image holder
|
||||||
|
if ($('#game-' + app.id).length === 0) {
|
||||||
|
// double clicking the button will cause multiple box arts to appear.
|
||||||
|
// to mitigate this we ensure we don't add a duplicate.
|
||||||
|
// This isn't perfect: there's lots of RTTs before the logic prevents anything
|
||||||
var imageBlob = new Blob([resolvedPromise], {type: "image/png"});
|
var imageBlob = new Blob([resolvedPromise], {type: "image/png"});
|
||||||
$("#game-grid").append($("<div>", {html:$("<img \>", {src: URL.createObjectURL(imageBlob), id: 'game-'+app.id, name: app.title }), class: 'box-art mdl-cell mdl-cell--3-col'}).append($("<span>", {html: app.title, class:"game-title"})));
|
$("#game-grid").append($("<div>", {html:$("<img \>", {src: URL.createObjectURL(imageBlob), id: 'game-'+app.id, name: app.title }), class: 'box-art mdl-cell mdl-cell--3-col'}).append($("<span>", {html: app.title, class:"game-title"})));
|
||||||
$('#game-'+app.id).on('click', startGame);
|
$('#game-'+app.id).on('click', startGame);
|
||||||
|
|
||||||
// apply CSS stylization to indicate whether the app is active
|
// apply CSS stylization to indicate whether the app is active
|
||||||
stylizeBoxArt(api, app.id);
|
stylizeBoxArt(api, app.id);
|
||||||
|
}
|
||||||
|
|
||||||
}, function (failedPromise) {
|
}, function (failedPromise) {
|
||||||
console.log('Error! Failed to retrieve box art for app ID: ' + app.id + '. Returned value was: ' + failedPromise)
|
console.log('Error! Failed to retrieve box art for app ID: ' + app.id + '. Returned value was: ' + failedPromise)
|
||||||
@ -333,9 +336,10 @@ function showApps() {
|
|||||||
console.log(api.toString());
|
console.log(api.toString());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
if ($('quitCurrentApp').length === 0) { // also prevent duplicate quit buttons from showing up
|
||||||
$("#game-grid").append($("<div>", {html:$("<img src=static\\res\\ic_remove_circle_white_24px.svg id=quitCurrentApp\>"), class: 'cancel-cell mdl-cell mdl-cell--3-col'}).append($("<span>", {html: 'Quit Current App', class:"game-title"})));
|
$("#game-grid").append($("<div>", {html:$("<img src=static\\res\\ic_remove_circle_white_24px.svg id=quitCurrentApp\>"), class: 'cancel-cell mdl-cell mdl-cell--3-col'}).append($("<span>", {html: 'Quit Current App', class:"game-title"})));
|
||||||
$('#quitCurrentApp').on('click', function() {api.quitApp(); api.refreshServerInfo(); });
|
$('#quitCurrentApp').on('click', function() {api.quitApp(); api.refreshServerInfo(); });
|
||||||
|
}
|
||||||
|
|
||||||
}, function (failedAppList) {
|
}, function (failedAppList) {
|
||||||
console.log('Failed to get applist from host: ' + api.address);
|
console.log('Failed to get applist from host: ' + api.address);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user