fix(platform): unblock UI by deferring P2P mesh startup after session restore
platform.ready() no longer awaits Hyperswarm discovery/contacts or guild mesh join before returning. Local identity and guild list restore in ~ms; _finishSessionStartup() runs meshes in the background and emits session-ready. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -158,6 +158,14 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
this.userSettings.on('prefs', () => this.emit('user-prefs'))
|
this.userSettings.on('prefs', () => this.emit('user-prefs'))
|
||||||
}
|
}
|
||||||
this.guilds = await this.listGuilds()
|
this.guilds = await this.listGuilds()
|
||||||
|
void this._finishSessionStartup()
|
||||||
|
}
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Guild mesh + discovery/contacts — background so UI can restore without blocking. */
|
||||||
|
async _finishSessionStartup () {
|
||||||
|
try {
|
||||||
if (this.guilds.length && !this.guild && this.mode !== 'dm') {
|
if (this.guilds.length && !this.guild && this.mode !== 'dm') {
|
||||||
await this.loadGuild(this.guilds[0].id)
|
await this.loadGuild(this.guilds[0].id)
|
||||||
}
|
}
|
||||||
@@ -165,8 +173,10 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
await this._joinContactsMesh()
|
await this._joinContactsMesh()
|
||||||
await this._joinSettingsMesh()
|
await this._joinSettingsMesh()
|
||||||
await this._initDeviceSync()
|
await this._initDeviceSync()
|
||||||
|
this.emit('session-ready')
|
||||||
|
} catch (err) {
|
||||||
|
this.emit('session-error', err)
|
||||||
}
|
}
|
||||||
return this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async _initDeviceSync () {
|
async _initDeviceSync () {
|
||||||
@@ -244,10 +254,7 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
await this.boosts.ready()
|
await this.boosts.ready()
|
||||||
this._forumTagFilter = null
|
this._forumTagFilter = null
|
||||||
this.guilds = await this.listGuilds()
|
this.guilds = await this.listGuilds()
|
||||||
await this._joinDiscoveryMesh()
|
void this._finishSessionStartup()
|
||||||
await this._joinContactsMesh()
|
|
||||||
await this._joinSettingsMesh()
|
|
||||||
await this._initDeviceSync()
|
|
||||||
this.emit('user', user)
|
this.emit('user', user)
|
||||||
return user
|
return user
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user