From d0a437f8fb9939e220595b0d4ad2478f294fe8d2 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Wed, 14 Dec 2022 16:03:10 -0600 Subject: Improve handling of connection loss --- src/state/models/feed-view.ts | 2 +- src/state/models/post-thread-view.ts | 6 +- src/state/models/reposted-by-view.ts | 6 +- src/state/models/votes-view.ts | 6 +- src/view/com/util/ViewHeader.tsx | 136 ++++++++++++++--------------------- 5 files changed, 69 insertions(+), 87 deletions(-) (limited to 'src') diff --git a/src/state/models/feed-view.ts b/src/state/models/feed-view.ts index 503e2a4c6..50906f3b2 100644 --- a/src/state/models/feed-view.ts +++ b/src/state/models/feed-view.ts @@ -393,7 +393,7 @@ export class FeedModel { } private async _loadMore() { - if (!this.hasMore) { + if (!this.hasMore || this.hasError) { return } this._xLoading() diff --git a/src/state/models/post-thread-view.ts b/src/state/models/post-thread-view.ts index ea9d123d0..ebe5b730d 100644 --- a/src/state/models/post-thread-view.ts +++ b/src/state/models/post-thread-view.ts @@ -312,7 +312,11 @@ export class PostThreadViewModel { private async _resolveUri() { const urip = new AtUri(this.params.uri) if (!urip.host.startsWith('did:')) { - urip.host = await this.rootStore.resolveName(urip.host) + try { + urip.host = await this.rootStore.resolveName(urip.host) + } catch (e: any) { + this.error = e.toString() + } } runInAction(() => { this.resolvedUri = urip.toString() diff --git a/src/state/models/reposted-by-view.ts b/src/state/models/reposted-by-view.ts index 4c61bafdc..9e9146899 100644 --- a/src/state/models/reposted-by-view.ts +++ b/src/state/models/reposted-by-view.ts @@ -104,7 +104,11 @@ export class RepostedByViewModel { private async _resolveUri() { const urip = new AtUri(this.params.uri) if (!urip.host.startsWith('did:')) { - urip.host = await this.rootStore.resolveName(urip.host) + try { + urip.host = await this.rootStore.resolveName(urip.host) + } catch (e: any) { + this.error = e.toString() + } } runInAction(() => { this.resolvedUri = urip.toString() diff --git a/src/state/models/votes-view.ts b/src/state/models/votes-view.ts index 6e9130e90..64da6b227 100644 --- a/src/state/models/votes-view.ts +++ b/src/state/models/votes-view.ts @@ -102,7 +102,11 @@ export class VotesViewModel { private async _resolveUri() { const urip = new AtUri(this.params.uri) if (!urip.host.startsWith('did:')) { - urip.host = await this.rootStore.resolveName(urip.host) + try { + urip.host = await this.rootStore.resolveName(urip.host) + } catch (e: any) { + this.error = e.toString() + } } runInAction(() => { this.resolvedUri = urip.toString() diff --git a/src/view/com/util/ViewHeader.tsx b/src/view/com/util/ViewHeader.tsx index 76fac8b9d..27f424573 100644 --- a/src/view/com/util/ViewHeader.tsx +++ b/src/view/com/util/ViewHeader.tsx @@ -48,89 +48,71 @@ export const ViewHeader = observer(function ViewHeader({ } canGoBack ??= store.nav.tab.canGoBack return ( - <> - - - {canGoBack ? ( - - ) : ( - - )} - - - {title} - {subtitle ? ( - - {subtitle} - - ) : undefined} - - - - - - + + {canGoBack ? ( + + ) : ( + - + )} + + + {title} + {subtitle ? ( + + {subtitle} + + ) : undefined} + + + + + + {!store.session.online ? ( - + {store.session.attemptingConnect ? ( - <> - - - Connecting... - - + ) : ( <> - + - - Unable to connect - - - Try again - )} ) : undefined} - + ) }) @@ -180,24 +162,12 @@ const styles = StyleSheet.create({ }, offline: { - flexDirection: 'row', - alignItems: 'center', - backgroundColor: colors.gray6, - paddingLeft: 15, - paddingRight: 10, - paddingVertical: 8, - borderRadius: 8, - marginHorizontal: 4, - marginTop: 4, + backgroundColor: colors.white, }, offlineBtn: { - backgroundColor: colors.gray5, + backgroundColor: colors.white, borderRadius: 5, paddingVertical: 5, paddingHorizontal: 10, }, - offlineBtnText: { - color: colors.white, - fontWeight: 'bold', - }, }) -- cgit 1.4.1