Skip to content

Commit

Permalink
Player: use reportFault second param object for setting targetId (#2117)
Browse files Browse the repository at this point in the history
* Player: use reportFault second param object for setting targetId
relates to xibosignageltd/xibo-private#264

* Player: call xiboIC.expireNow when data is not found after XHR request
relates to xibosignageltd/xibo-private#264
  • Loading branch information
rubenberttpingol authored Sep 29, 2023
1 parent 2609281 commit f944a5f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions modules/src/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ $(function() {
xiboIC.reportFault({
code: '5001',
reason: 'No Data',
});
}, {targetId: widget.widgetId});
}

onDataError(httpStatus, response);
} else {
xiboIC.reportFault({
code: '5001',
reason: 'No Data',
});
}, {targetId: widget.widgetId});
}
}

Expand Down Expand Up @@ -191,10 +191,18 @@ $(function() {
onDataErrorCallback(widget, data.error, data);
}

if (Array.isArray(data) && data.length === 0) {
xiboIC.expireNow({targetId: xiboICTargetId});
}

resolve(data);
}).fail(function(jqXHR, textStatus, errorThrown) {
onDataErrorCallback(widget, jqXHR.status, jqXHR.responseJSON);
console.log(jqXHR, textStatus, errorThrown);

if (jqXHR.status === 404) {
xiboIC.expireNow({targetId: xiboICTargetId});
}
});
} else {
resolve(null);
Expand Down Expand Up @@ -284,10 +292,6 @@ $(function() {
widget.items = [];
const $target = $('body');

if (dataItems.length === 0 && showError) {
xiboIC.expireNow({targetId: widget.widgetId});
}

if (showError && data?.message) {
$target.append(
'<div class="error-message" role="alert">' +
Expand Down Expand Up @@ -335,7 +339,7 @@ $(function() {

// IF we added item template
templateAlreadyAdded = true;
};
}

// Add item to the widget object
(item) && widget.items.push(item);
Expand Down Expand Up @@ -486,10 +490,6 @@ $(function() {
dataItems,
showError,
) {
if (dataItems.length === 0 && showError) {
xiboIC.expireNow({targetId: widget.widgetId});
}

// Parse out the template with elements.
if (elements?.length > 0) {
const $content = $('#content');
Expand Down

0 comments on commit f944a5f

Please sign in to comment.