Convert FeedbackDialog to TS

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
pull/21833/head
Šimon Brandner 2021-09-04 16:36:01 +02:00
parent 6aefd9318f
commit 8791b10ca9
No known key found for this signature in database
GPG Key ID: 55C211A1226CB17D
2 changed files with 16 additions and 8 deletions

View File

@ -30,6 +30,8 @@ const HEARTBEAT_INTERVAL = 5_000; // ms
const SESSION_UPDATE_INTERVAL = 60; // seconds const SESSION_UPDATE_INTERVAL = 60; // seconds
const MAX_PENDING_EVENTS = 1000; const MAX_PENDING_EVENTS = 1000;
export type Rating = 1 | 2 | 3 | 4 | 5;
enum Orientation { enum Orientation {
Landscape = "landscape", Landscape = "landscape",
Portrait = "portrait", Portrait = "portrait",
@ -451,7 +453,7 @@ export default class CountlyAnalytics {
window.removeEventListener("scroll", this.onUserActivity); window.removeEventListener("scroll", this.onUserActivity);
} }
public reportFeedback(rating: 1 | 2 | 3 | 4 | 5, comment: string) { public reportFeedback(rating: Rating, comment: string) {
this.track<IStarRatingEvent>("[CLY]_star_rating", { rating, comment }, null, {}, true); this.track<IStarRatingEvent>("[CLY]_star_rating", { rating, comment }, null, {}, true);
} }

View File

@ -19,7 +19,7 @@ import QuestionDialog from './QuestionDialog';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
import Field from "../elements/Field"; import Field from "../elements/Field";
import AccessibleButton from "../elements/AccessibleButton"; import AccessibleButton from "../elements/AccessibleButton";
import CountlyAnalytics from "../../../CountlyAnalytics"; import CountlyAnalytics, { Rating } from "../../../CountlyAnalytics";
import SdkConfig from "../../../SdkConfig"; import SdkConfig from "../../../SdkConfig";
import Modal from "../../../Modal"; import Modal from "../../../Modal";
import BugReportDialog from "./BugReportDialog"; import BugReportDialog from "./BugReportDialog";
@ -30,19 +30,23 @@ const existingIssuesUrl = "https://github.com/vector-im/element-web/issues" +
"?q=is%3Aopen+is%3Aissue+sort%3Areactions-%2B1-desc"; "?q=is%3Aopen+is%3Aissue+sort%3Areactions-%2B1-desc";
const newIssueUrl = "https://github.com/vector-im/element-web/issues/new/choose"; const newIssueUrl = "https://github.com/vector-im/element-web/issues/new/choose";
export default (props) => { interface IProps {
const [rating, setRating] = useState(""); onFinished: () => void;
const [comment, setComment] = useState(""); }
const onDebugLogsLinkClick = () => { const FeedbackDialog: React.FC<IProps> = (props: IProps) => {
const [rating, setRating] = useState<string>();
const [comment, setComment] = useState<string>("");
const onDebugLogsLinkClick = (): void => {
props.onFinished(); props.onFinished();
Modal.createTrackedDialog('Bug Report Dialog', '', BugReportDialog, {}); Modal.createTrackedDialog('Bug Report Dialog', '', BugReportDialog, {});
}; };
const hasFeedback = CountlyAnalytics.instance.canEnable(); const hasFeedback = CountlyAnalytics.instance.canEnable();
const onFinished = (sendFeedback) => { const onFinished = (sendFeedback: boolean): void => {
if (hasFeedback && sendFeedback) { if (hasFeedback && sendFeedback) {
CountlyAnalytics.instance.reportFeedback(parseInt(rating, 10), comment); CountlyAnalytics.instance.reportFeedback((parseInt(rating) as Rating), comment);
Modal.createTrackedDialog('Feedback sent', '', InfoDialog, { Modal.createTrackedDialog('Feedback sent', '', InfoDialog, {
title: _t('Feedback sent'), title: _t('Feedback sent'),
description: _t('Thank you!'), description: _t('Thank you!'),
@ -142,3 +146,5 @@ export default (props) => {
onFinished={onFinished} onFinished={onFinished}
/>); />);
}; };
export default FeedbackDialog;