Fix conversation view when remote returns error

This commit is contained in:
xmflsct 2023-01-15 21:51:27 +01:00
parent f10d52cebc
commit b52b529550
2 changed files with 41 additions and 32 deletions

View File

@ -68,9 +68,9 @@ PODS:
- libwebp/mux (1.2.4):
- libwebp/demux
- libwebp/webp (1.2.4)
- MMKV (1.2.14):
- MMKVCore (~> 1.2.14)
- MMKVCore (1.2.14)
- MMKV (1.2.15):
- MMKVCore (~> 1.2.15)
- MMKVCore (1.2.15)
- RCT-Folly (2021.07.22.00):
- boost
- DoubleConversion
@ -321,6 +321,8 @@ PODS:
- react-native-paste-input (0.5.2):
- React-Core
- Swime (= 3.0.6)
- react-native-quick-base64 (2.0.5):
- React-Core
- react-native-safe-area-context (4.4.1):
- RCT-Folly
- RCTRequired
@ -508,6 +510,7 @@ DEPENDENCIES:
- "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)"
- react-native-pager-view (from `../node_modules/react-native-pager-view`)
- "react-native-paste-input (from `../node_modules/@mattermost/react-native-paste-input`)"
- react-native-quick-base64 (from `../node_modules/react-native-quick-base64`)
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
- "react-native-segmented-control (from `../node_modules/@react-native-community/segmented-control`)"
- React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
@ -652,6 +655,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-pager-view"
react-native-paste-input:
:path: "../node_modules/@mattermost/react-native-paste-input"
react-native-quick-base64:
:path: "../node_modules/react-native-quick-base64"
react-native-safe-area-context:
:path: "../node_modules/react-native-safe-area-context"
react-native-segmented-control:
@ -732,8 +737,8 @@ SPEC CHECKSUMS:
hermes-engine: 2af7b7a59128f250adfd86f15aa1d5a2ecd39995
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
libwebp: f62cb61d0a484ba548448a4bd52aabf150ff6eef
MMKV: 9c4663aa7ca255d478ff10f2f5cb7d17c1651ccd
MMKVCore: 89f5c8a66bba2dcd551779dea4d412eeec8ff5bb
MMKV: 7f34558bbb5a33b0eaefae2de4b6a20a2ffdad6f
MMKVCore: ddf41b9d9262f058419f9ba7598719af56c02cd3
RCT-Folly: 0080d0a6ebf2577475bda044aa59e2ca1f909cda
RCTRequired: e1866f61af7049eb3d8e08e8b133abd38bc1ca7a
RCTTypeSafety: 27c2ac1b00609a432ced1ae701247593f07f901e
@ -760,6 +765,7 @@ SPEC CHECKSUMS:
react-native-netinfo: 2517ad504b3d303e90d7a431b0fcaef76d207983
react-native-pager-view: 54bed894cecebe28cede54c01038d9d1e122de43
react-native-paste-input: 88709b4fd586ea8cc56ba5e2fc4cdfe90597730c
react-native-quick-base64: e657e9197e61b60a9dec49807843052b830da254
react-native-safe-area-context: 99b24a0c5acd0d5dcac2b1a7f18c49ea317be99a
react-native-segmented-control: 65df6cd0619b780b3843d574a72d4c7cec396097
React-perflogger: 8c79399b0500a30ee8152d0f9f11beae7fc36595

View File

@ -146,33 +146,35 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
return Promise.resolve([{ ...toot }])
}
ancestorsCache.current = context.ancestors.map(ancestor => {
const localMatch = ancestorsCache.current?.find(local => local.uri === ancestor.uri)
if (localMatch) {
return { ...localMatch, _level: 0 }
} else {
return {
...ancestor,
_remote: true,
account: { ...ancestor.account, _remote: true },
mentions: ancestor.mentions.map(mention => ({
...mention,
_remote: true
})),
...(ancestor.reblog && {
reblog: {
...ancestor.reblog,
_remote: true,
account: { ...ancestor.reblog.account, _remote: true },
mentions: ancestor.reblog.mentions.map(mention => ({
...mention,
_remote: true
}))
}
})
if ((ancestorsCache.current?.length || 0) < context.ancestors.length) {
ancestorsCache.current = context.ancestors.map(ancestor => {
const localMatch = ancestorsCache.current?.find(local => local.uri === ancestor.uri)
if (localMatch) {
return localMatch
} else {
return {
...ancestor,
_remote: true,
account: { ...ancestor.account, _remote: true },
mentions: ancestor.mentions.map(mention => ({
...mention,
_remote: true
})),
...(ancestor.reblog && {
reblog: {
...ancestor.reblog,
_remote: true,
account: { ...ancestor.reblog.account, _remote: true },
mentions: ancestor.reblog.mentions.map(mention => ({
...mention,
_remote: true
}))
}
})
}
}
}
})
})
}
const statuses = [{ ...toot }, ...context.descendants]
return statuses.map((status, index) => {
@ -239,7 +241,8 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
}
)
}
},
onSettled: async () => {
loaded.current = true
if (ancestorsCache.current?.length) {