diff --git a/public/pages/Home/Home.page.tsx b/public/pages/Home/Home.page.tsx index a0b1c4f7c..077139cbc 100644 --- a/public/pages/Home/Home.page.tsx +++ b/public/pages/Home/Home.page.tsx @@ -79,7 +79,7 @@ What can we do better? This is the place for you to vote, discuss and share idea
- +
diff --git a/public/pages/Home/components/PostInput.tsx b/public/pages/Home/components/PostInput.tsx index 894c78783..32cf0a2ea 100644 --- a/public/pages/Home/components/PostInput.tsx +++ b/public/pages/Home/components/PostInput.tsx @@ -1,14 +1,16 @@ import React, { useState, useEffect, useRef } from "react" import { Button, ButtonClickEvent, Input, Form, TextArea, MultiImageUploader } from "@fider/components" import { SignInModal } from "@fider/components" -import { cache, actions, Failure } from "@fider/services" -import { ImageUpload } from "@fider/models" +import { cache, actions, Failure, navigator, querystring } from "@fider/services" +import { ImageUpload, Tag } from "@fider/models" import { useFider } from "@fider/hooks" import { t, Trans } from "@lingui/macro" +import { TagsFilter } from "./TagsFilter" interface PostInputProps { placeholder: string onTitleChanged: (title: string) => void + tags: Tag[] } const CACHE_TITLE_KEY = "PostInput-Title" @@ -26,6 +28,7 @@ export const PostInput = (props: PostInputProps) => { const titleRef = useRef() const [title, setTitle] = useState(getCachedValue(CACHE_TITLE_KEY)) const [description, setDescription] = useState(getCachedValue(CACHE_DESCRIPTION_KEY)) + const [tags, setTags] = useState(querystring.getArray("tags")) const [isSignInModalOpen, setIsSignInModalOpen] = useState(false) const [attachments, setAttachments] = useState([]) const [error, setError] = useState(undefined) @@ -57,7 +60,7 @@ export const PostInput = (props: PostInputProps) => { const submit = async (event: ButtonClickEvent) => { if (title) { - const result = await actions.createPost(title, description, attachments) + const result = await actions.createPost(title, description, attachments, tags) if (result.ok) { clearError() cache.session.remove(CACHE_TITLE_KEY, CACHE_DESCRIPTION_KEY) @@ -69,6 +72,19 @@ export const PostInput = (props: PostInputProps) => { } } + const handleTagsChanged = (newTags: string[]) => { + setTags(newTags) + + navigator.replaceState( + querystring.stringify({ + view: querystring.get("view"), + query: querystring.get("query"), + tags: newTags, + limit: querystring.getNumber("limit"), + }) + ) + } + const details = () => ( <>