video
-
onAddVideo(null)}>
+
onAddVideo(undefined)}>
{closeSvg}
diff --git a/src/app/decks/_components/deck-threads-form/deck-threads-form-toolbar-image-picker.tsx b/src/app/decks/_components/deck-threads-form/deck-threads-form-toolbar-image-picker.tsx
index 19dafb65f..482846a82 100644
--- a/src/app/decks/_components/deck-threads-form/deck-threads-form-toolbar-image-picker.tsx
+++ b/src/app/decks/_components/deck-threads-form/deck-threads-form-toolbar-image-picker.tsx
@@ -1,17 +1,17 @@
import React, { useRef, useState } from "react";
import axios from "axios";
import { Button } from "@ui/button";
-import { UilImage } from "@tooni/iconscout-unicons-react";
+import { UilImage, UilLink, UilUpload } from "@tooni/iconscout-unicons-react";
import { useGlobalStore } from "@/core/global-store";
import { getAccessToken } from "@/utils";
import { uploadImage } from "@/api/misc";
import { error } from "@/features/shared";
import i18next from "i18next";
import { Tooltip } from "@ui/tooltip";
-import { PopperDropdown } from "@/features/ui";
import { AddImage } from "@/features/shared/editor-toolbar/add-image";
import { GalleryDialog } from "@/features/shared/gallery";
import { EcencyConfigManager } from "@/config";
+import { Dropdown, DropdownItemWithIcon, DropdownMenu, DropdownToggle } from "@ui/dropdown";
interface Props {
onAddImage: (link: string, name: string) => void;
@@ -76,43 +76,39 @@ export const DeckThreadsFormToolbarImagePicker = ({ onAddImage }: Props) => {
{activeUser && (
- } appearance="gray-link" noPadding={true} />}
- >
-
-
{
- setImagePickInitiated(true);
- }}
- >
- {i18next.t("editor-toolbar.link-image")}
-
-
) => {
+
+
+ } appearance="gray-link" noPadding={true} />
+
+
+ setImagePickInitiated(true)}
+ icon={}
+ label={i18next.t("editor-toolbar.link-image")}
+ />
+ {
e.stopPropagation();
const el = fileInputRef.current;
if (el) el.click();
}}
- >
- {i18next.t("editor-toolbar.upload")}
-
+ icon={
}
+ label={i18next.t("editor-toolbar.upload")}
+ />
visionFeatures.gallery.enabled}
>
- ) => {
+ {
e.stopPropagation();
setGalleryPickInitiated(true);
}}
- >
- {i18next.t("editor-toolbar.gallery")}
-
+ icon={}
+ label={i18next.t("editor-toolbar.gallery")}
+ />
-
-
+
+
)}
{imagePickInitiated && (
diff --git a/src/app/decks/_components/deck-threads-form/index.tsx b/src/app/decks/_components/deck-threads-form/index.tsx
index 7efd4c26e..e7ea849a3 100644
--- a/src/app/decks/_components/deck-threads-form/index.tsx
+++ b/src/app/decks/_components/deck-threads-form/index.tsx
@@ -7,13 +7,11 @@ import useLocalStorage from "react-use/lib/useLocalStorage";
import { DeckThreadsCreatedRecently } from "./deck-threads-created-recently";
import { IdentifiableEntry, ThreadItemEntry } from "../columns/deck-threads-manager";
import useClickAway from "react-use/lib/useClickAway";
-import usePrevious from "react-use/lib/usePrevious";
import { Button } from "@ui/button";
import { Alert } from "@ui/alert";
import { Entry } from "@/entities";
import { useGlobalStore } from "@/core/global-store";
import { PollsContext } from "@/features/polls";
-import { useLocation } from "react-use";
import { PREFIX } from "@/utils/local-storage";
import i18next from "i18next";
import { AvailableCredits, UserAvatar } from "@/features/shared";
@@ -51,20 +49,15 @@ export const DeckThreadsForm = ({
const { setShow, create, createReply } = useContext(DeckThreadsFormContext);
const { clearActivePoll } = useContext(PollsContext);
- const location = useLocation();
-
const [localDraft, setLocalDraft] = useLocalStorage
>(
PREFIX + "_local_draft",
{}
);
- const [persistedForm, setPersistedForm] = useLocalStorage>(PREFIX + "_dtf_f");
- const previousPersistedForm = usePrevious(persistedForm);
-
- const [threadHost, setThreadHost] = useState("ecency.waves");
- const [text, setText] = useState("");
- const [image, setImage] = useState(null);
- const [imageName, setImageName] = useState(null);
- const [video, setVideo] = useState(null);
+ const [threadHost, setThreadHost] = useLocalStorage(PREFIX + "_dtf_th", "ecency.waves");
+ const [text, setText, clearText] = useLocalStorage(PREFIX + "_dtf_t", "");
+ const [image, setImage, clearImage] = useLocalStorage(PREFIX + "_dtf_i");
+ const [imageName, setImageName, clearImageName] = useLocalStorage(PREFIX + "_dtf_in");
+ const [video, setVideo, clearVideo] = useLocalStorage(PREFIX + "_dtf_v");
const [disabled, setDisabled] = useState(true);
const [loading, setLoading] = useState(false);
@@ -91,63 +84,7 @@ export const DeckThreadsForm = ({
}
setText(nextText);
}
- }, [entry]);
-
- useEffect(() => {
- if (persistable) {
- if (!threadHost && persistedForm?.threadHost) {
- setThreadHost(persistedForm.threadHost);
- }
-
- if (!text && persistedForm?.text) {
- setText(persistedForm.text);
- }
-
- if (!image && persistedForm?.image) {
- setImage(persistedForm.image);
- }
-
- if (!imageName && persistedForm?.imageName) {
- setImageName(persistedForm.imageName);
- }
-
- if (!video && persistedForm?.video) {
- setVideo(persistedForm.video);
- }
- }
- }, [image, imageName, persistable, persistedForm, text, threadHost, video]);
-
- useEffect(() => {
- if (
- persistable &&
- (persistedForm?.threadHost !== threadHost ||
- persistedForm?.text !== text ||
- persistedForm?.image !== image ||
- persistedForm?.imageName !== imageName ||
- persistedForm?.video !== video)
- ) {
- setPersistedForm({
- threadHost,
- text,
- image,
- imageName,
- video
- });
- }
- }, [
- threadHost,
- text,
- image,
- imageName,
- persistable,
- persistedForm?.threadHost,
- persistedForm?.text,
- persistedForm?.image,
- persistedForm?.imageName,
- persistedForm?.video,
- video,
- setPersistedForm
- ]);
+ }, [entry, setImage, setText]);
const submit = async () => {
if (!activeUser) {
@@ -203,9 +140,9 @@ export const DeckThreadsForm = ({
if (onSuccess) {
onSuccess(threadItem);
}
- setText("");
- setImage(null);
- setImageName(null);
+ clearText();
+ clearImage();
+ clearImageName();
clearActivePoll();
i18next.t("decks.threads-form.successfully-created");
} catch (e) {
@@ -224,15 +161,15 @@ export const DeckThreadsForm = ({
>
{!activeUser &&
!entry &&
- text?.length <= 255 &&
+ (text?.length ?? 0) <= 255 &&
i18next.t("decks.threads-form.login-and-publish")}
{activeUser &&
!entry &&
- text?.length <= 255 &&
+ (text?.length ?? 0) <= 255 &&
(loading
? i18next.t("decks.threads-form.publishing")
: i18next.t("decks.threads-form.publish"))}
- {text?.length > 255 && !entry && i18next.t("decks.threads-form.create-regular-post")}
+ {(text?.length ?? 0) > 255 && !entry && i18next.t("decks.threads-form.create-regular-post")}
{entry && i18next.t("decks.threads-form.save")}
);
@@ -273,7 +210,10 @@ export const DeckThreadsForm = ({
setImageName(name);
}}
onAddVideo={setVideo}
- setSelectedImage={setImage}
+ onClearImage={() => {
+ clearImage();
+ clearImageName();
+ }}
placeholder={placeholder}
onTextareaFocus={() => setFocused(true)}
/>
@@ -287,12 +227,12 @@ export const DeckThreadsForm = ({
)}
- {inline && text?.length > 255 && (
+ {inline && (text?.length ?? 0) > 255 && (
- {text?.length > 255 && (
+ {(text?.length ?? 0) > 255 && (
{i18next.t("decks.threads-form.max-length")}
)}
& Props) {
a]:text-dark-default dark:text-white dark:[&>a]:text-white rounded-tr-2xl rounded-br-2xl":
+ "min-w-[80%] cursor-pointer [&>a]:text-dark-default dark:text-white dark:[&>a]:text-white rounded-tr-2xl rounded-br-2xl duration-200":
true,
"bg-blue-dark-sky-040 text-blue-dark-sky dark:bg-gray-900 hover:bg-blue-dark-sky-030 dark:hover:bg-gray-800":
props.selected ?? false,
- "hover:bg-blue-dark-sky-040 text-dark-default hover:text-blue-dark-sky dark:hover:bg-gray-900 ":
+ "hover:bg-blue-dark-sky-040 text-dark-default hover:text-blue-dark-sky dark:hover:bg-dark-default":
!(props.selected ?? false),
"px-4 py-2": !props.size || props.size === "medium",
"px-2 py-1 text-sm": !props.size || props.size === "small",