Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

User logged out bugs

Matt Roberts541c48179524
diff --git a/public/components/common/form/CommentEditor.tsx b/public/components/common/form/CommentEditor.tsx
index 59df11bfc..ee4471b71 100644
--- a/public/components/common/form/CommentEditor.tsx
+++ b/public/components/common/form/CommentEditor.tsx
@@ -10,6 +10,7 @@ import { UserNames } from "@fider/models"
import { actions } from "@fider/services"
import "./CommentEditor.scss"
+import { useFider } from "@fider/hooks"
export type TextType = { text: string }
@@ -62,7 +63,6 @@ const Portal = ({ children }: { children?: ReactNode }) => {
interface CommentEditorProps {
initialValue?: string
- disabled?: boolean
placeholder?: string
onChange?: (value: string) => void
onFocus?: React.FocusEventHandler<HTMLDivElement>
@@ -92,6 +92,7 @@ export const CommentEditor: React.FunctionComponent<CommentEditorProps> = (props
const [target, setTarget] = useState<Range | undefined>()
const [index, setIndex] = useState(0)
const [search, setSearch] = useState("")
+ const fider = useFider()
// Fetch users when component mounts
useEffect(() => {
@@ -101,7 +102,9 @@ export const CommentEditor: React.FunctionComponent<CommentEditorProps> = (props
setUsers(result.data)
}
}
- loadUsers()
+ if (fider.session.isAuthenticated) {
+ loadUsers()
+ }
}, [])
const renderElement = useCallback((props: RenderElementProps) => <SlateElement {...props} />, [])
@@ -190,10 +193,11 @@ export const CommentEditor: React.FunctionComponent<CommentEditorProps> = (props
}}
>
<Editable
- readOnly={props.disabled}
+ readOnly={false}
className="slate-editor"
renderElement={renderElement}
onKeyDown={onKeyDown}
+ onFocus={props.onFocus}
placeholder={props.placeholder}
renderPlaceholder={Placeholder}
/>
diff --git a/public/pages/ShowPost/components/CommentInput.tsx b/public/pages/ShowPost/components/CommentInput.tsx
index 9c37d7a23..e2fc0fa2a 100644
--- a/public/pages/ShowPost/components/CommentInput.tsx
+++ b/public/pages/ShowPost/components/CommentInput.tsx
@@ -48,6 +48,7 @@ export const CommentInput = (props: CommentInputProps) => {
}
const editorFocused = () => {
+ console.log("focused")
if (!fider.session.isAuthenticated) {
setIsSignInModalOpen(true)
}
@@ -76,7 +77,6 @@ export const CommentInput = (props: CommentInputProps) => {
initialValue={content}
onChange={commentChanged}
onFocus={editorFocused}
- disabled={!Fider.session.isAuthenticated}
placeholder={i18n._("showpost.commentinput.placeholder", { message: "Leave a comment" })}
/>
{hasContent && (
diff --git a/public/services/toastify.tsx b/public/services/toastify.tsx
index ec0e8cb93..4eab273b8 100644
--- a/public/services/toastify.tsx
+++ b/public/services/toastify.tsx
@@ -1,6 +1,6 @@
import { I18nProvider } from "@lingui/react"
import React from "react"
-import ReactDOM from "react-dom"
+import ReactDOM from "react-dom/client"
import { i18n } from "@lingui/core"
import { ToastContainer, toast, ToastContent, ToastOptions } from "react-toastify"
@@ -11,15 +11,17 @@ let hasContainer = false
const setup = () => {
if (!hasContainer) {
hasContainer = true
- ReactDOM.render(
- <I18nProvider i18n={i18n}>
- <ToastContainer position={toast.POSITION.TOP_RIGHT} />
- </I18nProvider>,
- document.getElementById("root-toastify")
- )
+ const rootElement = document.getElementById("root-toastify")
+ if (rootElement) {
+ const root = ReactDOM.createRoot(rootElement)
+ root.render(
+ <I18nProvider i18n={i18n}>
+ <ToastContainer position={toast.POSITION.TOP_RIGHT} />
+ </I18nProvider>
+ )
+ }
}
}
-
export const success = (content: ToastContent, options?: ToastOptions) => {
setup()
toast.success(content, options)