Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds toast and resets compose content #138

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions apps/builddao/widget/Compose.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const [showAccountAutocomplete, setShowAccountAutocomplete] = useState(false);
const [mentionsArray, setMentionsArray] = useState([]);
const [mentionInput, setMentionInput] = useState(null);
const [handler, setHandler] = useState("update");
const [showToast, setShowToast] = useState(false);

const [composeKey, setComposeKey] = useState(0);
const memoizedComposeKey = useMemo(() => composeKey, [composeKey]);
Expand Down Expand Up @@ -139,7 +140,9 @@ const postToCustomFeed = ({ feed, text }) => {
onCommit: () => {
setPostContent("");
Storage.privateSet(draftKey, props.template || "");
setComposeKey(generateUID());
setHandler("autocompleteSelected"); // this is a hack to force the iframe to update
setShowToast(true);
},
onCancel: () => {
// console.log(`Cancelled ${feed}: #${postId}`);
Expand Down Expand Up @@ -444,6 +447,7 @@ return (
<TextareaWrapper
className="markdown-editor"
data-value={postContent || ""}
key={memoizedComposeKey}
>
<Widget
src={"buildhub.near/widget/components.MarkdownEditorIframe"}
Expand Down Expand Up @@ -522,5 +526,25 @@ return (
{postBtnText ?? "Post"}
</Button>
</div>
<Widget
src="near/widget/DIG.Toast"
props={{
title: "Post Submitted Successfully",
type: "success",
open: showToast,
onOpenChange: (v) => showToast(v),
trigger: <></>,
action: (
<Button
variant="primary"
style={{ fontSize: 14 }}
onClick={() => showToast(false)}
>
dismiss
</Button>
),
providerProps: { duration: 1000 },
}}
/>
</PostCreator>
);