mirror of
https://github.com/urbit/shrub.git
synced 2024-11-28 13:54:20 +03:00
Merge pull request #5041 from urbit/lf/reconnect-fetch
interface: omnibus
This commit is contained in:
commit
0930dea484
@ -14,13 +14,7 @@ export const bootstrapApi = async () => {
|
|||||||
|
|
||||||
airlock.onError = (e) => {
|
airlock.onError = (e) => {
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
useLocalState.setState({ subscription: 'disconnected' });
|
||||||
useLocalState.setState({ subscription: 'reconnecting' });
|
|
||||||
airlock.reset();
|
|
||||||
await bootstrapApi();
|
|
||||||
} catch (e) {
|
|
||||||
useLocalState.setState({ subscription: 'disconnected' });
|
|
||||||
}
|
|
||||||
})();
|
})();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ const useMetadataState = createState<MetadataState>(
|
|||||||
return state.previews[group];
|
return state.previews[group];
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const preview = await airlock.subscribeOnce('metadata-pull-hook', `/preview${group}`);
|
const preview = await airlock.subscribeOnce('metadata-pull-hook', `/preview${group}`, 20 * 1000);
|
||||||
if('metadata-hook-update' in preview) {
|
if('metadata-hook-update' in preview) {
|
||||||
const newState = get();
|
const newState = get();
|
||||||
newState.set((s) => {
|
newState.set((s) => {
|
||||||
|
@ -28,8 +28,8 @@ function sidebarSort(
|
|||||||
const lastUpdated = (a: string, b: string) => {
|
const lastUpdated = (a: string, b: string) => {
|
||||||
const aAssoc = associations[a];
|
const aAssoc = associations[a];
|
||||||
const bAssoc = associations[b];
|
const bAssoc = associations[b];
|
||||||
const aResource = aAssoc.resource;
|
const aResource = aAssoc?.resource;
|
||||||
const bResource = bAssoc.resource;
|
const bResource = bAssoc?.resource;
|
||||||
|
|
||||||
const aUpdated = a.startsWith('~')
|
const aUpdated = a.startsWith('~')
|
||||||
? (unreads?.[`/ship/~${window.ship}/dm-inbox`]?.[`/${patp2dec(a)}`]?.last || 0)
|
? (unreads?.[`/ship/~${window.ship}/dm-inbox`]?.[`/${patp2dec(a)}`]?.last || 0)
|
||||||
|
@ -52,6 +52,11 @@ export class Urbit {
|
|||||||
*/
|
*/
|
||||||
private outstandingSubscriptions: Map<number, SubscriptionRequestInterface> = new Map();
|
private outstandingSubscriptions: Map<number, SubscriptionRequestInterface> = new Map();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Our abort controller, used to close the connection
|
||||||
|
*/
|
||||||
|
private abort = new AbortController();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ship can be set, in which case we can do some magic stuff like send chats
|
* Ship can be set, in which case we can do some magic stuff like send chats
|
||||||
*/
|
*/
|
||||||
@ -88,7 +93,8 @@ export class Urbit {
|
|||||||
return {
|
return {
|
||||||
credentials: 'include',
|
credentials: 'include',
|
||||||
accept: '*',
|
accept: '*',
|
||||||
headers
|
headers,
|
||||||
|
signal: this.abort
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,6 +264,9 @@ export class Urbit {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
reset() {
|
reset() {
|
||||||
|
this.delete();
|
||||||
|
this.abort.abort();
|
||||||
|
this.abort = new AbortController();
|
||||||
this.uid = `${Math.floor(Date.now() / 1000)}-${hexString(6)}`;
|
this.uid = `${Math.floor(Date.now() / 1000)}-${hexString(6)}`;
|
||||||
this.lastEventId = 0;
|
this.lastEventId = 0;
|
||||||
this.lastAcknowledgedEventId = 0;
|
this.lastAcknowledgedEventId = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user