Browse Source

fix: intermittent unsubscriber err breaking pages

pages would stop loading completely and require a refresh due to a
'unsubscriber lexicon' error
master
DanConwayDev 2 years ago
parent
commit
5882c9744f
No known key found for this signature in database
GPG Key ID: 68E15486D73F75E1
  1. 2
      src/lib/stores/repo.ts
  2. 4
      src/lib/stores/repos.ts
  3. 8
      src/lib/stores/users.ts

2
src/lib/stores/repo.ts

@ -52,7 +52,7 @@ export const awaitSelectedRepoCollection = async (
!repo_collection.loading !repo_collection.loading
) { ) {
setTimeout(() => { setTimeout(() => {
unsubscriber() if (unsubscriber) unsubscriber()
}, 5) }, 5)
r({ ...repo_collection }) r({ ...repo_collection })
} }

4
src/lib/stores/repos.ts

@ -25,7 +25,9 @@ export const returnRepoCollection = async (
unique_commit_or_identifier unique_commit_or_identifier
).subscribe((c) => { ).subscribe((c) => {
if (!c.loading) { if (!c.loading) {
unsubscriber() setTimeout(() => {
if (unsubscriber) unsubscriber()
}, 5)
r(c) r(c)
} }
}) })

8
src/lib/stores/users.ts

@ -49,7 +49,9 @@ export const returnUser = async (hexpubkey: string): Promise<User> => {
return new Promise((r) => { return new Promise((r) => {
const unsubscriber = ensureUser(hexpubkey).subscribe((u) => { const unsubscriber = ensureUser(hexpubkey).subscribe((u) => {
if (!u.loading) { if (!u.loading) {
unsubscriber() setTimeout(() => {
if (unsubscriber) unsubscriber()
}, 5)
r(u) r(u)
} }
}) })
@ -123,7 +125,9 @@ export const getUserRelays = async (hexpubkey: string): Promise<UserRelays> => {
(querying_user_relays) => { (querying_user_relays) => {
if (querying_user_relays && !querying_user_relays.loading) { if (querying_user_relays && !querying_user_relays.loading) {
res(querying_user_relays) res(querying_user_relays)
if (unsubscriber) unsubscriber() setTimeout(() => {
if (unsubscriber) unsubscriber()
}, 5)
} }
} }
) )

Loading…
Cancel
Save