diff --git a/packages/app/src/components/PostCard/components/attachments/index.jsx b/packages/app/src/components/PostCard/components/attachments/index.jsx
index 47a04b0a..d1adb65a 100755
--- a/packages/app/src/components/PostCard/components/attachments/index.jsx
+++ b/packages/app/src/components/PostCard/components/attachments/index.jsx
@@ -30,7 +30,7 @@ import "plyr-react/dist/plyr.css"
import "./index.less"
const Attachment = React.memo((props) => {
- const { url, id, name } = props.attachment
+ const { url, id } = props.attachment
const [loaded, setLoaded] = React.useState(false)
@@ -108,9 +108,19 @@ const Attachment = React.memo((props) => {
return
}
- return
- {renderMedia()}
-
+ try {
+ return
+ {renderMedia()}
+
+ } catch (error) {
+ console.error(`Failed to render attachment ${props.attachment.name} (${props.attachment.id})`, error)
+
+ return
+ }
})
export default (props) => {
@@ -158,8 +168,8 @@ export default (props) => {
stopOnHover={true}
>
{
- props.attachments.map((attachment, index) => {
- return
+ props.attachments?.length > 0 && props.attachments.map((attachment, index) => {
+ return
})
}
diff --git a/packages/app/src/components/PostCard/components/content/index.jsx b/packages/app/src/components/PostCard/components/content/index.jsx
index 3a2ffc50..e517ae13 100755
--- a/packages/app/src/components/PostCard/components/content/index.jsx
+++ b/packages/app/src/components/PostCard/components/content/index.jsx
@@ -8,19 +8,10 @@ import { processString } from "utils"
import "./index.less"
export default (props) => {
- let { message, data } = props.data
+ let { message } = props.data
const [nsfwAccepted, setNsfwAccepted] = React.useState(false)
- if (typeof data === "string") {
- try {
- data = JSON.parse(data)
- } catch (error) {
- console.error(error)
- data = {}
- }
- }
-
// parse message
const regexs = [
{
diff --git a/packages/app/src/components/PostCard/index.jsx b/packages/app/src/components/PostCard/index.jsx
index a871ee4d..c9ce8f01 100755
--- a/packages/app/src/components/PostCard/index.jsx
+++ b/packages/app/src/components/PostCard/index.jsx
@@ -133,58 +133,72 @@ export default ({
return
}
- return
-
-
-
- {data.attachments && data.attachments.length > 0 && }
-
-
- {!fullmode &&
-
-
+ try {
+ return
+
+
+
+ {data.attachments && data.attachments.length > 0 && }
+
- }
- {!fullmode &&
-
- }
-
+ {!fullmode &&
+
+
+
+ }
+ {!fullmode &&
+
+ }
+
+ } catch (error) {
+ console.error(error)
+
+ return
+
+
+ Cannot render this post
+
+ Maybe this version of the app is outdated or is not supported yet
+
+
+
+ }
}
\ No newline at end of file