Improve handling of connection loss
parent
568ff92582
commit
d0a437f8fb
|
@ -393,7 +393,7 @@ export class FeedModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _loadMore() {
|
private async _loadMore() {
|
||||||
if (!this.hasMore) {
|
if (!this.hasMore || this.hasError) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this._xLoading()
|
this._xLoading()
|
||||||
|
|
|
@ -312,7 +312,11 @@ export class PostThreadViewModel {
|
||||||
private async _resolveUri() {
|
private async _resolveUri() {
|
||||||
const urip = new AtUri(this.params.uri)
|
const urip = new AtUri(this.params.uri)
|
||||||
if (!urip.host.startsWith('did:')) {
|
if (!urip.host.startsWith('did:')) {
|
||||||
|
try {
|
||||||
urip.host = await this.rootStore.resolveName(urip.host)
|
urip.host = await this.rootStore.resolveName(urip.host)
|
||||||
|
} catch (e: any) {
|
||||||
|
this.error = e.toString()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
this.resolvedUri = urip.toString()
|
this.resolvedUri = urip.toString()
|
||||||
|
|
|
@ -104,7 +104,11 @@ export class RepostedByViewModel {
|
||||||
private async _resolveUri() {
|
private async _resolveUri() {
|
||||||
const urip = new AtUri(this.params.uri)
|
const urip = new AtUri(this.params.uri)
|
||||||
if (!urip.host.startsWith('did:')) {
|
if (!urip.host.startsWith('did:')) {
|
||||||
|
try {
|
||||||
urip.host = await this.rootStore.resolveName(urip.host)
|
urip.host = await this.rootStore.resolveName(urip.host)
|
||||||
|
} catch (e: any) {
|
||||||
|
this.error = e.toString()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
this.resolvedUri = urip.toString()
|
this.resolvedUri = urip.toString()
|
||||||
|
|
|
@ -102,7 +102,11 @@ export class VotesViewModel {
|
||||||
private async _resolveUri() {
|
private async _resolveUri() {
|
||||||
const urip = new AtUri(this.params.uri)
|
const urip = new AtUri(this.params.uri)
|
||||||
if (!urip.host.startsWith('did:')) {
|
if (!urip.host.startsWith('did:')) {
|
||||||
|
try {
|
||||||
urip.host = await this.rootStore.resolveName(urip.host)
|
urip.host = await this.rootStore.resolveName(urip.host)
|
||||||
|
} catch (e: any) {
|
||||||
|
this.error = e.toString()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
this.resolvedUri = urip.toString()
|
this.resolvedUri = urip.toString()
|
||||||
|
|
|
@ -48,18 +48,13 @@ export const ViewHeader = observer(function ViewHeader({
|
||||||
}
|
}
|
||||||
canGoBack ??= store.nav.tab.canGoBack
|
canGoBack ??= store.nav.tab.canGoBack
|
||||||
return (
|
return (
|
||||||
<>
|
|
||||||
<View style={styles.header}>
|
<View style={styles.header}>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={canGoBack ? onPressBack : onPressMenu}
|
onPress={canGoBack ? onPressBack : onPressMenu}
|
||||||
hitSlop={BACK_HITSLOP}
|
hitSlop={BACK_HITSLOP}
|
||||||
style={canGoBack ? styles.backIcon : styles.backIconWide}>
|
style={canGoBack ? styles.backIcon : styles.backIconWide}>
|
||||||
{canGoBack ? (
|
{canGoBack ? (
|
||||||
<FontAwesomeIcon
|
<FontAwesomeIcon size={18} icon="angle-left" style={{marginTop: 6}} />
|
||||||
size={18}
|
|
||||||
icon="angle-left"
|
|
||||||
style={{marginTop: 6}}
|
|
||||||
/>
|
|
||||||
) : (
|
) : (
|
||||||
<UserAvatar
|
<UserAvatar
|
||||||
size={30}
|
size={30}
|
||||||
|
@ -93,44 +88,31 @@ export const ViewHeader = observer(function ViewHeader({
|
||||||
style={styles.searchBtnIcon}
|
style={styles.searchBtnIcon}
|
||||||
/>
|
/>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
|
||||||
{!store.session.online ? (
|
{!store.session.online ? (
|
||||||
<TouchableOpacity style={styles.offline} onPress={onPressReconnect}>
|
<TouchableOpacity
|
||||||
|
style={[styles.btn, {marginLeft: 8}, styles.offline]}
|
||||||
|
onPress={onPressReconnect}>
|
||||||
{store.session.attemptingConnect ? (
|
{store.session.attemptingConnect ? (
|
||||||
<>
|
|
||||||
<ActivityIndicator />
|
<ActivityIndicator />
|
||||||
<Text style={[s.gray1, s.bold, s.flex1, s.pl5, s.pt5, s.pb5]}>
|
|
||||||
Connecting...
|
|
||||||
</Text>
|
|
||||||
</>
|
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<FontAwesomeIcon icon="signal" style={[s.gray2]} size={18} />
|
<FontAwesomeIcon icon="signal" style={[s.black]} size={18} />
|
||||||
<FontAwesomeIcon
|
<FontAwesomeIcon
|
||||||
icon="x"
|
icon="x"
|
||||||
style={[
|
style={{
|
||||||
s.red4,
|
backgroundColor: colors.white,
|
||||||
{
|
color: colors.red4,
|
||||||
backgroundColor: colors.gray6,
|
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
left: -4,
|
left: -4,
|
||||||
top: 6,
|
top: 6,
|
||||||
},
|
}}
|
||||||
]}
|
|
||||||
border
|
|
||||||
size={12}
|
size={12}
|
||||||
/>
|
/>
|
||||||
<Text style={[s.gray1, s.bold, s.flex1, s.pl2]}>
|
|
||||||
Unable to connect
|
|
||||||
</Text>
|
|
||||||
<View style={styles.offlineBtn}>
|
|
||||||
<Text style={styles.offlineBtnText}>Try again</Text>
|
|
||||||
</View>
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
) : undefined}
|
) : undefined}
|
||||||
</>
|
</View>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -180,24 +162,12 @@ const styles = StyleSheet.create({
|
||||||
},
|
},
|
||||||
|
|
||||||
offline: {
|
offline: {
|
||||||
flexDirection: 'row',
|
backgroundColor: colors.white,
|
||||||
alignItems: 'center',
|
|
||||||
backgroundColor: colors.gray6,
|
|
||||||
paddingLeft: 15,
|
|
||||||
paddingRight: 10,
|
|
||||||
paddingVertical: 8,
|
|
||||||
borderRadius: 8,
|
|
||||||
marginHorizontal: 4,
|
|
||||||
marginTop: 4,
|
|
||||||
},
|
},
|
||||||
offlineBtn: {
|
offlineBtn: {
|
||||||
backgroundColor: colors.gray5,
|
backgroundColor: colors.white,
|
||||||
borderRadius: 5,
|
borderRadius: 5,
|
||||||
paddingVertical: 5,
|
paddingVertical: 5,
|
||||||
paddingHorizontal: 10,
|
paddingHorizontal: 10,
|
||||||
},
|
},
|
||||||
offlineBtnText: {
|
|
||||||
color: colors.white,
|
|
||||||
fontWeight: 'bold',
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue