mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-10 10:05:09 +03:00
Add support for POST delete channel requests using navigator.sendBeacon
This commit is contained in:
parent
b40b20a88d
commit
f55fa3bd2f
@ -623,10 +623,10 @@
|
||||
//
|
||||
delete() {
|
||||
var id = this.nextId();
|
||||
this.sendJSONToChannel({
|
||||
navigator.sendBeacon(this.channelURL(), JSON.stringify([{
|
||||
"id": id,
|
||||
"action": "delete"
|
||||
}, false);
|
||||
}]));
|
||||
}
|
||||
|
||||
// unsubscribe to a specific subscription
|
||||
@ -642,7 +642,7 @@
|
||||
|
||||
// sends a JSON command command to the server.
|
||||
//
|
||||
sendJSONToChannel(j, connectAgain = true) {
|
||||
sendJSONToChannel(j) {
|
||||
var req = new XMLHttpRequest();
|
||||
req.open("PUT", this.channelURL());
|
||||
req.setRequestHeader("Content-Type", "application/json");
|
||||
@ -663,9 +663,7 @@
|
||||
this.lastEventId = this.lastAcknowledgedEventId;
|
||||
}
|
||||
|
||||
if (connectAgain) {
|
||||
this.connectIfDisconnected();
|
||||
}
|
||||
this.connectIfDisconnected();
|
||||
}
|
||||
|
||||
// connects to the EventSource if we are not currently connected
|
||||
@ -1109,6 +1107,9 @@
|
||||
::
|
||||
?: =('GET' method.request)
|
||||
(on-get-request channel-id request)
|
||||
?: =('POST' method.request)
|
||||
:: POST methods are used solely for deleting channels
|
||||
(on-put-request channel-id request)
|
||||
::
|
||||
~& %session-not-a-put
|
||||
[~ state]
|
||||
|
Loading…
Reference in New Issue
Block a user