mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-01 09:00:03 +01:00
* Refresh UI notifications automatically on update * make notif timeago live * pass cancellation token * Update InvoiceEventData.cs
27 lines
940 B
Text
27 lines
940 B
Text
<div></div>
|
|
@await Component.InvokeAsync("NotificationsDropdown")
|
|
<script>
|
|
|
|
var supportsWebSockets = 'WebSocket' in window && window.WebSocket.CLOSING === 2;
|
|
|
|
if (supportsWebSockets) {
|
|
var ws_uri = "@Url.Action("SubscribeUpdates", "Notifications", new {}, Context.Request.Scheme)".replace("http", "ws");
|
|
var newDataEndpoint = "@Url.Action("GetNotificationDropdownUI", "Notifications", new {}, Context.Request.Scheme)";
|
|
|
|
try {
|
|
socket = new WebSocket(ws_uri);
|
|
socket.onmessage = function (e) {
|
|
$.get(newDataEndpoint, function(data){
|
|
$("#notifications-nav-item").replaceWith($(data));
|
|
});
|
|
};
|
|
socket.onerror = function (e) {
|
|
console.error("Error while connecting to websocket for notifications (callback)", e);
|
|
};
|
|
}
|
|
catch (e) {
|
|
console.error("Error while connecting to websocket for notifications", e);
|
|
}
|
|
}
|
|
|
|
</script>
|