gubes mirror. how does this work
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

covid

leah 5f1031ff 2f473837

+42 -26
+16 -15
core/connection.ts
··· 294 294 return this.nickname; 295 295 } 296 296 297 - try_and_reconnect = false; 298 297 retry_interval = 0; 299 298 retry_count = 0; 300 299 $recovering = signal(false); 301 300 302 301 protected async recover_connection() { 303 - if (!this.try_and_reconnect) { 304 - return; 305 - } 306 - if (this.retry_count > 5) { 307 - this.try_and_reconnect = false; 302 + console.log("Recovering connection"); 303 + this.$recovering.value = true; 304 + try { 305 + await this.connect().catch(x => {}); 306 + } catch {} 307 + 308 + if (this.retry_count > 5 309 + || this.$state.value == ConnectionState.Connected 310 + ) { 308 311 this.$recovering.value = false; 309 312 this.retry_count = 0; 310 313 this.retry_interval = 0; 311 - 312 - return; 314 + } else { 315 + this.retry_interval += 10000; 316 + this.retry_count += 1; 317 + 318 + console.log(`Reconnection failed, trying again in ${this.retry_interval}ms`) 319 + 320 + setTimeout(() => this.recover_connection(), this.retry_interval); 313 321 } 314 - 315 - setTimeout(() => { 316 - this.$recovering.value = true; 317 - 318 - this.connect(); 319 - this.retry_interval += 10000; 320 - }, this.retry_interval); 321 322 } 322 323 323 324 /**
+9 -2
core/queue.ts
··· 76 76 77 77 export class Deferred<T = void, E = void> { 78 78 promise: Promise<T>; 79 + done = false; 79 80 resolve!: (message: T) => void; 80 81 reject!: (message: E) => void; 81 82 82 83 constructor() { 83 84 this.promise = new Promise((resolve, reject) => { 84 - this.resolve = resolve; 85 - this.reject = reject; 85 + this.resolve = (x) => { 86 + resolve(x); 87 + this.done = true; 88 + }; 89 + this.reject = (x) => { 90 + reject(x); 91 + this.done = true; 92 + }; 86 93 }) 87 94 } 88 95 }
+12 -6
core/ws/connection.ts
··· 40 40 this.ws.onopen = () => { this.#register(resolver) }; 41 41 this.ws.onmessage = (ev) => this.handle_incoming(ev.data as string); 42 42 this.ws.onclose = () => this.handle_disconnect(); 43 - this.ws.onerror = () => this.socket_error(); 43 + this.ws.onerror = () => { 44 + if (!resolver.done) resolver.reject(); 45 + this.socket_error(); 46 + } 44 47 45 48 return resolver.promise; 46 49 } ··· 117 120 } 118 121 119 122 private socket_error() { 120 - console.log("hi") 123 + console.log("Socket Error Moment!!!!") 124 + 125 + let reconnect = this.$state.value == ConnectionState.Connected; 121 126 122 - this.$state.value = ConnectionState.Failed; 123 127 this.$error.value = [ConnectionErrorCode.SocketError]; 124 - 125 - // this.try_and_reconnect = true; 126 - // this.recover_connection(); 128 + this.disconnect(ConnectionState.Failed); 129 + 130 + if (reconnect) { 131 + this.recover_connection(); 132 + } 127 133 } 128 134 129 135 async disconnect(target_state: ConnectionState = ConnectionState.Disconnected) {
+1 -1
neo/package.json
··· 14 14 "async-mutex": "^0.5.0", 15 15 "dayjs": "^1.11.13", 16 16 "dexie": "^4.0.8", 17 - "motion": "^11.12.0", 17 + "motion": "^10.18.0", 18 18 "preact": "^10.23.1", 19 19 "wouter-preact": "^3.3.1" 20 20 },
+2
neo/src/bits/sidebar/network-section.tsx
··· 171 171 172 172 {/* error message if there is one */} 173 173 {errored && <div class="connection-error"><ConnErrorMessage conn={conn} /></div>} 174 + 175 + {conn.$recovering.value && "Recovering..."} 174 176 175 177 {/* list of buffers */} 176 178 <ul class="sidebar-list">
+1
neo/src/buffer/view.tsx
··· 142 142 <p> 143 143 {channel.$topic.value} 144 144 </p> 145 + <p>{channel.$members.value.length}</p> 145 146 </header> 146 147 147 148 const StartOfHistory: FunctionalComponent<{ buffer: ChatBuffer }> = ({ buffer }) => {
-1
neo/src/chat/adapters.ts
··· 1 1 import { signal } from "@preact/signals"; 2 - import { store_message } from "@src/storage"; 3 2 import type { Adapter } from "tubes_core/adapter"; 4 3 import { SojuAdapter } from "tubes_core/soju/adapter"; 5 4 import tubes_handler from "./handler";
+1 -1
neo/src/css/messages.css
··· 1 1 .message-list { 2 2 display: grid; 3 - grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); 3 + grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); 4 4 grid-template-rows: auto 1fr auto; 5 5 justify-content: center; 6 6 max-height: 100vh;