Skip to content

Commit

Permalink
fix: feedback dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
ifaouibadi committed Feb 21, 2024
1 parent 854ddb1 commit 27eca08
Showing 1 changed file with 6 additions and 42 deletions.
48 changes: 6 additions & 42 deletions src/components/views/dialogs/FeedbackDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,20 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React, { useEffect, useRef, useState } from "react";
import QuestionDialog from "matrix-react-sdk/src/components/views/dialogs/QuestionDialog";
import { _t } from "matrix-react-sdk/src/languageHandler";
import Field from "matrix-react-sdk/src/components/views/elements/Field";
import AccessibleButton from "matrix-react-sdk/src/components/views/elements/AccessibleButton";
import SdkConfig from "matrix-react-sdk/src/SdkConfig";
import Modal from "matrix-react-sdk/src/Modal";
import SdkConfig from "matrix-react-sdk/src/SdkConfig";
import BugReportDialog from "matrix-react-sdk/src/components/views/dialogs/BugReportDialog";
import { useStateToggle } from "matrix-react-sdk/src/hooks/useStateToggle";
import StyledCheckbox from "matrix-react-sdk/src/components/views/elements/StyledCheckbox";
import QuestionDialog from "matrix-react-sdk/src/components/views/dialogs/QuestionDialog";
import AccessibleButton from "matrix-react-sdk/src/components/views/elements/AccessibleButton";
import ExternalLink from "matrix-react-sdk/src/components/views/elements/ExternalLink";
import { MatrixClientPeg } from "matrix-react-sdk/src/MatrixClientPeg";
import { _t } from "matrix-react-sdk/src/languageHandler";
import React from "react";
interface IProps {
feature?: string;
onFinished(): void;
}

const FeedbackDialog: React.FC<IProps> = (props: IProps) => {
const feedbackRef = useRef<Field>(null);
const [comment, setComment] = useState<string>("");
const [canContact, toggleCanContact] = useStateToggle(false);
const client = MatrixClientPeg.safeGet();

useEffect(() => {
// autofocus doesn't work on textareas
feedbackRef.current?.focus();
}, []);

const onDebugLogsLinkClick = (): void => {
props.onFinished();
Modal.createDialog(BugReportDialog, {});
Expand All @@ -53,9 +39,6 @@ const FeedbackDialog: React.FC<IProps> = (props: IProps) => {
const onFinished = async (sendFeedback: boolean): Promise<void> => {
if (hasFeedback && sendFeedback) {
window.open(`#/room/${supportChannelRoomId}`, "_self");

const actualRoomId = await client.getRoomIdForAlias(supportChannelRoomId);
client.sendTextMessage(actualRoomId.room_id, comment);
}
props.onFinished();
};
Expand All @@ -66,25 +49,7 @@ const FeedbackDialog: React.FC<IProps> = (props: IProps) => {
<div className="mx_FeedbackDialog_section mx_FeedbackDialog_rateApp">
<h3>{_t("feedback|comment_label")}</h3>

{/* <p>{_t("feedback|platform_username")}</p> */}
<p>Ready to make a difference? Drop a message to share your feedback, thoughts, or suggestions.</p>

<Field
id="feedbackComment"
label={_t("common|feedback")}
type="text"
autoComplete="off"
value={comment}
element="textarea"
onChange={(ev) => {
setComment(ev.target.value);
}}
ref={feedbackRef}
/>

<StyledCheckbox checked={canContact} onChange={toggleCanContact}>
{_t("feedback|may_contact_label")}
</StyledCheckbox>
</div>
);
}
Expand Down Expand Up @@ -114,7 +79,7 @@ const FeedbackDialog: React.FC<IProps> = (props: IProps) => {
return (
<QuestionDialog
className="mx_FeedbackDialog"
hasCancelButton={hasFeedback}
hasCancelButton={false}
title={_t("common|feedback")}
description={
<React.Fragment>
Expand Down Expand Up @@ -152,7 +117,6 @@ const FeedbackDialog: React.FC<IProps> = (props: IProps) => {
</React.Fragment>
}
button={hasFeedback ? _t("feedback|send_feedback_action") : _t("action|go_back")}
buttonDisabled={hasFeedback && !comment}
onFinished={onFinished}
/>
);
Expand Down

0 comments on commit 27eca08

Please sign in to comment.