Skip to content

Commit 2d99aca

Browse files
authored
typescript src/room (#437)
1 parent c723fae commit 2d99aca

37 files changed

+467
-286
lines changed

src/@types/global.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ declare global {
2424

2525
// TypeScript doesn't know about the experimental setSinkId method, so we
2626
// declare it ourselves
27-
interface MediaElement extends HTMLMediaElement {
27+
interface MediaElement extends HTMLVideoElement {
2828
setSinkId: (id: string) => void;
2929
}
3030
}

src/ClientContext.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ export const ClientProvider: FC<Props> = ({ children }) => {
132132
isAuthenticated: Boolean(client),
133133
isPasswordlessUser,
134134
userName: client?.getUserIdLocalpart(),
135+
error: undefined,
135136
});
136137
})
137138
.catch(() => {
@@ -141,6 +142,7 @@ export const ClientProvider: FC<Props> = ({ children }) => {
141142
isAuthenticated: false,
142143
isPasswordlessUser: false,
143144
userName: null,
145+
error: undefined,
144146
});
145147
});
146148
}, []);
@@ -170,6 +172,7 @@ export const ClientProvider: FC<Props> = ({ children }) => {
170172
isAuthenticated: true,
171173
isPasswordlessUser: false,
172174
userName: client.getUserIdLocalpart(),
175+
error: undefined,
173176
});
174177
},
175178
[client]
@@ -190,6 +193,7 @@ export const ClientProvider: FC<Props> = ({ children }) => {
190193
isAuthenticated: true,
191194
isPasswordlessUser: session.passwordlessUser,
192195
userName: newClient.getUserIdLocalpart(),
196+
error: undefined,
193197
});
194198
} else {
195199
clearSession();
@@ -200,6 +204,7 @@ export const ClientProvider: FC<Props> = ({ children }) => {
200204
isAuthenticated: false,
201205
isPasswordlessUser: false,
202206
userName: null,
207+
error: undefined,
203208
});
204209
}
205210
},
@@ -258,6 +263,7 @@ export const ClientProvider: FC<Props> = ({ children }) => {
258263
logout,
259264
userName,
260265
setClient,
266+
error: undefined,
261267
}),
262268
[
263269
loading,

src/Menu.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useRef, useState } from "react";
1+
import React, { Key, useRef, useState } from "react";
22
import { AriaMenuOptions, useMenu, useMenuItem } from "@react-aria/menu";
33
import { TreeState, useTreeState } from "@react-stately/tree";
44
import { mergeProps } from "@react-aria/utils";
@@ -9,15 +9,17 @@ import { Node } from "@react-types/shared";
99
import styles from "./Menu.module.css";
1010

1111
interface MenuProps<T> extends AriaMenuOptions<T> {
12-
className: String;
13-
onAction: () => void;
14-
onClose: () => void;
12+
className?: String;
13+
onClose?: () => void;
14+
onAction: (value: Key) => void;
15+
label?: string;
1516
}
1617

1718
export function Menu<T extends object>({
1819
className,
1920
onAction,
2021
onClose,
22+
label,
2123
...rest
2224
}: MenuProps<T>) {
2325
const state = useTreeState<T>({ ...rest, selectionMode: "none" });
@@ -46,7 +48,7 @@ export function Menu<T extends object>({
4648
interface MenuItemProps<T> {
4749
item: Node<T>;
4850
state: TreeState<T>;
49-
onAction: () => void;
51+
onAction: (value: Key) => void;
5052
onClose: () => void;
5153
}
5254

src/SequenceDiagramViewerPage.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@ limitations under the License.
1616

1717
import React, { useCallback, useState } from "react";
1818

19-
import { SequenceDiagramViewer } from "./room/GroupCallInspector";
19+
import {
20+
SequenceDiagramViewer,
21+
SequenceDiagramMatrixEvent,
22+
} from "./room/GroupCallInspector";
2023
import { FieldRow, InputField } from "./input/Input";
2124
import { usePageTitle } from "./usePageTitle";
2225

2326
interface DebugLog {
2427
localUserId: string;
25-
eventsByUserId: Record<string, {}>;
28+
eventsByUserId: { [userId: string]: SequenceDiagramMatrixEvent[] };
2629
remoteUserIds: string[];
2730
}
2831

@@ -33,7 +36,7 @@ export function SequenceDiagramViewerPage() {
3336
const [selectedUserId, setSelectedUserId] = useState<string>();
3437
const onChangeDebugLog = useCallback((e) => {
3538
if (e.target.files && e.target.files.length > 0) {
36-
e.target.files[0].text().then((text) => {
39+
e.target.files[0].text().then((text: string) => {
3740
setDebugLog(JSON.parse(text));
3841
});
3942
}

src/UserMenuContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface Props {
1111
preventNavigation?: boolean;
1212
}
1313

14-
export function UserMenuContainer({ preventNavigation }: Props) {
14+
export function UserMenuContainer({ preventNavigation = false }: Props) {
1515
const location = useLocation();
1616
const history = useHistory();
1717
const { isAuthenticated, isPasswordlessUser, logout, userName, client } =

src/auth/RegisterPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export const RegisterPage: FC = () => {
100100
submit()
101101
.then(() => {
102102
if (location.state?.from) {
103-
history.push(location.state.from);
103+
history.push(location.state?.from);
104104
} else {
105105
history.push("/");
106106
}

src/button/Button.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ interface Props {
7474
children: Element[];
7575
onPress: (e: PressEvent) => void;
7676
onPressStart: (e: PressEvent) => void;
77+
// TODO: add all props for <Button>
7778
[index: string]: unknown;
7879
}
7980
export const Button = forwardRef<HTMLButtonElement, Props>(
@@ -136,6 +137,7 @@ export function MicButton({
136137
...rest
137138
}: {
138139
muted: boolean;
140+
// TODO: add all props for <Button>
139141
[index: string]: unknown;
140142
}) {
141143
return (
@@ -154,6 +156,7 @@ export function VideoButton({
154156
...rest
155157
}: {
156158
muted: boolean;
159+
// TODO: add all props for <Button>
157160
[index: string]: unknown;
158161
}) {
159162
return (
@@ -174,6 +177,7 @@ export function ScreenshareButton({
174177
}: {
175178
enabled: boolean;
176179
className?: string;
180+
// TODO: add all props for <Button>
177181
[index: string]: unknown;
178182
}) {
179183
return (
@@ -192,6 +196,7 @@ export function HangupButton({
192196
...rest
193197
}: {
194198
className?: string;
199+
// TODO: add all props for <Button>
195200
[index: string]: unknown;
196201
}) {
197202
return (
@@ -212,6 +217,7 @@ export function SettingsButton({
212217
...rest
213218
}: {
214219
className?: string;
220+
// TODO: add all props for <Button>
215221
[index: string]: unknown;
216222
}) {
217223
return (
@@ -228,6 +234,7 @@ export function InviteButton({
228234
...rest
229235
}: {
230236
className?: string;
237+
// TODO: add all props for <Button>
231238
[index: string]: unknown;
232239
}) {
233240
return (

src/button/CopyButton.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import { Button, ButtonVariant } from "./Button";
2323

2424
interface Props {
2525
value: string;
26-
children?: JSX.Element;
27-
className: string;
28-
variant: ButtonVariant;
26+
children?: JSX.Element | string;
27+
className?: string;
28+
variant?: ButtonVariant;
2929
copiedMessage?: string;
3030
}
3131
export function CopyButton({

src/button/LinkButton.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,32 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import React, { ReactNode } from "react";
17+
import React, { HTMLAttributes } from "react";
1818
import { Link } from "react-router-dom";
1919
import classNames from "classnames";
20+
import * as H from "history";
2021

2122
import {
2223
variantToClassName,
2324
sizeToClassName,
2425
ButtonVariant,
2526
ButtonSize,
2627
} from "./Button";
27-
interface Props {
28-
className?: string;
29-
variant?: ButtonVariant;
28+
29+
interface Props extends HTMLAttributes<HTMLAnchorElement> {
30+
children: JSX.Element | string;
31+
to: H.LocationDescriptor | ((location: H.Location) => H.LocationDescriptor);
3032
size?: ButtonSize;
31-
children: ReactNode;
32-
[index: string]: unknown;
33+
variant?: ButtonVariant;
34+
className?: string;
3335
}
3436

3537
export function LinkButton({
36-
className,
37-
variant,
38-
size,
3938
children,
39+
to,
40+
size,
41+
variant,
42+
className,
4043
...rest
4144
}: Props) {
4245
return (
@@ -46,6 +49,7 @@ export function LinkButton({
4649
sizeToClassName[size],
4750
className
4851
)}
52+
to={to}
4953
{...rest}
5054
>
5155
{children}

src/home/CallTypeDropdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const CallTypeDropdown: FC<Props> = ({ callType, setCallType }) => {
4646
{callType === CallType.Video ? "Video call" : "Walkie-talkie call"}
4747
</Headline>
4848
</Button>
49-
{(props) => (
49+
{(props: JSX.IntrinsicAttributes) => (
5050
<Menu {...props} label="Call type menu" onAction={setCallType}>
5151
<Item key={CallType.Video} textValue="Video call">
5252
<VideoIcon />

0 commit comments

Comments
 (0)