on master help sign in
sphinx/ui/src/api.ts
12 lines 485 B history raw
1import Urbit from "@urbit/http-api";
3const api = new Urbit('', '', window.desk);
4api.ship = window.ship;
6// @urbit/http-api 2.x adds `window.addEventListener('beforeunload', this.delete)`
7// unbound, so its beacon is sent to `${location dir}/undefined` (404) and the
8// channel is left open until eyre's 12h timeout. Replace it with a bound one.
9window.removeEventListener('beforeunload', api.delete);
10window.addEventListener('beforeunload', () => api.delete());
12export default api;