Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

Share feedback fixes (#1340)

Matt Robertse4e75729fe13
diff --git a/app/actions/signin.go b/app/actions/signin.go
index 982fce940..4b5a3ebeb 100644
--- a/app/actions/signin.go
+++ b/app/actions/signin.go
@@ -15,7 +15,6 @@ import (
// SignInByEmail happens when user request to sign in by email
type SignInByEmail struct {
Email string `json:"email" format:"lower"`
- Code string `json:"code"`
VerificationKey string
}
diff --git a/app/handlers/signin.go b/app/handlers/signin.go
index f359de44f..1f2812019 100644
--- a/app/handlers/signin.go
+++ b/app/handlers/signin.go
@@ -74,7 +74,7 @@ func SignInByEmail() web.HandlerFunc {
return c.Failure(err)
}
- c.Enqueue(tasks.SendSignInEmail(action.Email, action.Code, action.VerificationKey))
+ c.Enqueue(tasks.SendSignInEmail(action.Email, action.VerificationKey))
return c.Ok(web.Map{})
}
@@ -103,7 +103,6 @@ func VerifySignInKey(kind enum.EmailVerificationKind) web.HandlerFunc {
Data: web.Map{
"kind": kind,
"k": key,
- "c": c.QueryParam("c"),
},
})
}
@@ -118,9 +117,6 @@ func VerifySignInKey(kind enum.EmailVerificationKind) web.HandlerFunc {
webutil.AddAuthUserCookie(c, userByEmail.Result)
baseURL := c.BaseURL()
- if codeQs := c.QueryParam("c"); codeQs != "" {
- return c.Redirect(baseURL + "?c=" + codeQs)
- }
return c.Redirect(baseURL)
}
}
diff --git a/app/tasks/signin.go b/app/tasks/signin.go
index 07609e8d1..4980f4914 100644
--- a/app/tasks/signin.go
+++ b/app/tasks/signin.go
@@ -9,11 +9,11 @@ import (
)
// SendSignInEmail is used to send the sign in email to requestor
-func SendSignInEmail(email, code, verificationKey string) worker.Task {
+func SendSignInEmail(email, verificationKey string) worker.Task {
return describe("Send sign in email", func(c *worker.Context) error {
to := dto.NewRecipient("", email, dto.Props{
"siteName": c.Tenant().Name,
- "link": link(web.BaseURL(c), "/signin/verify?k=%s&c=%s", verificationKey, code),
+ "link": link(web.BaseURL(c), "/signin/verify?k=%s", verificationKey),
})
bus.Publish(c, &cmd.SendMail{
diff --git a/app/tasks/signin_test.go b/app/tasks/signin_test.go
index af05c1549..ee3ce22da 100644
--- a/app/tasks/signin_test.go
+++ b/app/tasks/signin_test.go
@@ -16,7 +16,7 @@ func TestSendSignInEmailTask(t *testing.T) {
bus.Init(emailmock.Service{})
worker := mock.NewWorker()
- task := tasks.SendSignInEmail("[email protected]", "9876", "9876")
+ task := tasks.SendSignInEmail("[email protected]", "9876")
err := worker.
OnTenant(mock.DemoTenant).
@@ -39,7 +39,7 @@ func TestSendSignInEmailTask(t *testing.T) {
Address: "[email protected]",
Props: dto.Props{
"siteName": mock.DemoTenant.Name,
- "link": "<a href='http://domain.com/signin/verify?k=9876&c=9876'>http://domain.com/signin/verify?k=9876&c=9876</a>",
+ "link": "<a href='http://domain.com/signin/verify?k=9876'>http://domain.com/signin/verify?k=9876</a>",
},
})
}
diff --git a/public/pages/Home/Home.page.tsx b/public/pages/Home/Home.page.tsx
index 6e30d330f..5f2ff549b 100644
--- a/public/pages/Home/Home.page.tsx
+++ b/public/pages/Home/Home.page.tsx
@@ -1,7 +1,7 @@
import "./Home.page.scss"
import NoDataIllustration from "@fider/assets/images/undraw-no-data.svg"
-import React, { useState } from "react"
+import React, { useEffect, useState } from "react"
import { Post, Tag, PostStatus } from "@fider/models"
import { Markdown, Hint, PoweredByFider, Icon, Header, Button } from "@fider/components"
import { PostsContainer } from "./components/PostsContainer"
@@ -10,7 +10,7 @@ import { VStack } from "@fider/components/layout"
import { ShareFeedback } from "./components/ShareFeedback"
import { i18n } from "@lingui/core"
import { Trans } from "@lingui/react/macro"
-import { isPostPending } from "./components/PostCache"
+import { isPostPending, setPostPending } from "./components/PostCache"
export interface HomePageProps {
posts: Post[]
@@ -49,6 +49,15 @@ const HomePage = (props: HomePageProps) => {
// const [title, setTitle] = useState("")
const [isShareFeedbackOpen, setIsShareFeedbackOpen] = useState(isPostPending())
+ useEffect(() => {
+ // If we're showing the share feedback, make sure we clear the show pending flag (for draft posts)
+ if (isShareFeedbackOpen) {
+ if (isPostPending()) {
+ setPostPending(false)
+ }
+ }
+ })
+
const defaultWelcomeMessage = i18n._({
id: "home.form.defaultwelcomemessage",
message: `We'd love to hear what you're thinking about.
@@ -80,7 +89,7 @@ What can we do better? This is the place for you to vote, discuss and share idea
<ShareFeedback
tags={props.tags}
placeholder={fider.session.tenant.invitation || defaultInvitation}
- isOpen={isShareFeedbackOpen}
+ isOpen={isShareFeedbackOpen && !fider.isReadOnly}
onClose={() => setIsShareFeedbackOpen(false)}
/>
<Header />
diff --git a/public/pages/Home/components/ShareFeedback.tsx b/public/pages/Home/components/ShareFeedback.tsx
index f37de6aa6..67e655da9 100644
--- a/public/pages/Home/components/ShareFeedback.tsx
+++ b/public/pages/Home/components/ShareFeedback.tsx
@@ -220,7 +220,7 @@ export const ShareFeedback: React.FC<ShareFeedbackProps> = (props) => {
onChange={handleDescriptionChange}
onFocus={handleEditorFocus}
initialValue={description}
- disabled={false}
+ disabled={fider.isReadOnly}
maxAttachments={3}
maxImageSizeKB={5 * 1024}
placeholder={i18n._({
@@ -238,6 +238,7 @@ export const ShareFeedback: React.FC<ShareFeedbackProps> = (props) => {
maxLength={255}
label={i18n._({ id: "newpost.modal.title.label", message: "Give your idea a title" })}
value={title}
+ disabled={fider.isReadOnly}
onChange={handleTitleChange}
placeholder={i18n._({ id: "newpost.modal.title.placeholder", message: "Something short and snappy, sum it up in a few words" })}
/>