Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: feedback dialog #63

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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