Skip to content

Commit

Permalink
Fix single post widget author photo always shown
Browse files Browse the repository at this point in the history
  • Loading branch information
irshadahmad21 committed Oct 12, 2024
1 parent 677c6c6 commit 28a8e65
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/loud-rockets-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wptelegram-widget": patch
---

Fixed the issue of single post widget author photo always shown
18 changes: 7 additions & 11 deletions plugins/wptelegram-widget/js/blocks/single-post/Edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function Edit(props: BlockEditProps<SinglePostAtts>) {
const [isEditingURL, setIsEditingURL] = useState(false);
const [url, setUrl] = useState(props.attributes.url || '');
const [userpic, setUserpic] = useState<boolean>(
props.attributes.userpic || true,
props.attributes.userpic ?? true,
);
const [iframeHeight, setIframeHeight] = useState(0);

Expand Down Expand Up @@ -63,17 +63,13 @@ export function Edit(props: BlockEditProps<SinglePostAtts>) {
.replace('%userpic%', `${userpic}`);
}

function toggleUserPic() {
setUserpic((prevValue) => {
const newValue = !prevValue;
function toggleUserPic(newValue: boolean) {
setIframeState('loading');
let { iframe_src } = props.attributes;
iframe_src = addQueryArgs(iframe_src, { userpic: newValue });
props.setAttributes({ userpic: newValue, iframe_src });

setIframeState('loading');
let { iframe_src } = props.attributes;
iframe_src = addQueryArgs(iframe_src, { userpic });
props.setAttributes({ userpic: newValue, iframe_src });

return newValue;
});
setUserpic(newValue);
}

function onChangeAlign(align: SinglePostAtts['alignment']) {
Expand Down

0 comments on commit 28a8e65

Please sign in to comment.