Reset link preview placeholder
This commit is contained in:
parent
b33754fa09
commit
7b84a516e5
|
|
@ -109,6 +109,8 @@ const MODE_FLOW_CONFIG = {
|
|||
},
|
||||
};
|
||||
|
||||
const LINK_PREVIEW_PLACEHOLDER = "https://assets.sociowire.com/placeholder/link.png";
|
||||
|
||||
export default function MapView({
|
||||
theme = "dark",
|
||||
onPostsState,
|
||||
|
|
@ -297,7 +299,9 @@ export default function MapView({
|
|||
const [draftImageMedium, setDraftImageMedium] = useState("");
|
||||
const [draftImageLarge, setDraftImageLarge] = useState("");
|
||||
const [draftImageFile, setDraftImageFile] = useState(null);
|
||||
const [draftImagePreview, setDraftImagePreview] = useState("");
|
||||
const [draftImagePreview, setDraftImagePreview] = useState(
|
||||
LINK_PREVIEW_PLACEHOLDER
|
||||
);
|
||||
const [draftMediaUrls, setDraftMediaUrls] = useState([]);
|
||||
const [useCustomImage, setUseCustomImage] = useState(false);
|
||||
const [postVisibility, setPostVisibility] = useState("public");
|
||||
|
|
@ -1036,8 +1040,11 @@ export default function MapView({
|
|||
setDraftSource("");
|
||||
setDraftPublishedAt("");
|
||||
setDraftImage("");
|
||||
setDraftImageSmall("");
|
||||
setDraftImageMedium("");
|
||||
setDraftImageLarge("");
|
||||
setDraftImageFile(null);
|
||||
setDraftImagePreview("");
|
||||
setDraftImagePreview(LINK_PREVIEW_PLACEHOLDER);
|
||||
setDraftMediaUrls([]);
|
||||
setUseCustomImage(false);
|
||||
setPostVisibility("public");
|
||||
|
|
@ -1254,6 +1261,9 @@ export default function MapView({
|
|||
const title = (data.title || "").trim();
|
||||
const desc = (data.description || "").trim();
|
||||
const image = (data.image || "").trim();
|
||||
const isPlaceholder =
|
||||
data.image_placeholder ||
|
||||
(image && image === LINK_PREVIEW_PLACEHOLDER);
|
||||
|
||||
if (!titleTouched && title) setDraftTitle(title);
|
||||
if (!bodyTouched && desc) setDraftBody(desc);
|
||||
|
|
@ -1261,11 +1271,16 @@ export default function MapView({
|
|||
if (data.source) setDraftSource(String(data.source));
|
||||
if (data.published_at) setDraftPublishedAt(String(data.published_at));
|
||||
|
||||
if (!imageTouched && image) {
|
||||
if (!imageTouched) {
|
||||
if (image && !isPlaceholder) {
|
||||
setUseCustomImage(true);
|
||||
if (!draftImageFile && !draftImagePreview) {
|
||||
addMediaUrlToGallery(image);
|
||||
}
|
||||
} else {
|
||||
setUseCustomImage(false);
|
||||
setDraftImagePreview(LINK_PREVIEW_PLACEHOLDER);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
setUrlPreviewError(err?.message || "Failed to fetch link preview");
|
||||
|
|
|
|||
Loading…
Reference in New Issue