Skip to content

Commit

Permalink
replace remaining client axios usage
Browse files Browse the repository at this point in the history
  • Loading branch information
howardchung committed Dec 25, 2024
1 parent 94dfde2 commit 521aaf8
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 29 deletions.
17 changes: 7 additions & 10 deletions src/components/Announce/Announce.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import axios from 'axios';
import React, { useCallback, useEffect, useState } from 'react';
import ReactMarkdown from 'react-markdown';
import { Button } from 'semantic-ui-react';
Expand All @@ -17,20 +16,18 @@ const Announce = () => {
const [announcement, setAnnouncement] = useState<Issue | null>(null);
useEffect(() => {
const fetch = async () => {
const response = await axios.get<{ items: Issue[] }>(
'https://api.github.com/search/issues',
{
params: {
const response = await window.fetch(
'https://api.github.com/search/issues?' +
new URLSearchParams({
q: `repo:${GITHUB_REPO} label:${
config.NODE_ENV === 'development' ? 'test' : 'release'
}`,
order: 'desc',
page: 1,
per_page: 1,
},
},
page: '1',
per_page: '1',
}),
);
const data = response.data;
const data: { items: Issue[] } = await response.json();
// console.log(data);
const top = data?.items?.[0];
if (
Expand Down
1 change: 0 additions & 1 deletion src/components/App/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type MediasoupClient from 'mediasoup-client';
import axios from 'axios';
import React from 'react';
import {
Button,
Expand Down
23 changes: 11 additions & 12 deletions src/components/Modal/ProfileModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Modal, Button, Icon, Image, Popup } from 'semantic-ui-react';
import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import { serverPath } from '../../utils';
import axios from 'axios';
import { ManageSubButton } from '../SubscribeButton/SubscribeButton';
import config from '../../config';
import { MetadataContext } from '../../MetadataContext';
Expand All @@ -22,17 +21,16 @@ export class ProfileModal extends React.Component<{
};

async componentDidMount() {
const token = await this.context.user?.getIdToken();
const response = await axios.get<LinkAccount[]>(
serverPath + '/linkAccount',
{
params: {
uid: this.context.user?.uid,
const token = (await this.context.user?.getIdToken()) ?? '';
const response = await fetch(
serverPath +
'/linkAccount?' +
new URLSearchParams({
uid: this.context.user?.uid ?? '',
token,
},
},
}),
);
const data = response.data;
const data: LinkAccount[] = await response.json();
const linkedDiscord = data.find((d) => d.kind === 'discord');
this.setState({ linkedDiscord });
}
Expand Down Expand Up @@ -125,8 +123,9 @@ export class ProfileModal extends React.Component<{
undone.
</p>
<p>
Note: If you have an active subscription, deleting your account will NOT
automatically cancel it and you will need to contact [email protected] to cancel.
Note: If you have an active subscription, deleting your account
will NOT automatically cancel it and you will need to contact
[email protected] to cancel.
</p>
</Modal.Content>
<Modal.Actions>
Expand Down
1 change: 0 additions & 1 deletion src/components/Settings/SettingsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from 'semantic-ui-react';
// import { SignInButton } from '../TopBar/TopBar';
import { getCurrentSettings, updateSettings } from './LocalSettings';
import axios from 'axios';
import { serverPath } from '../../utils';
import { PermanentRoomModal } from '../Modal/PermanentRoomModal';
import firebase from 'firebase/compat/app';
Expand Down
4 changes: 2 additions & 2 deletions src/components/TopBar/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import { LoginModal } from '../Modal/LoginModal';
import axios from 'axios';
import { SubscribeButton } from '../SubscribeButton/SubscribeButton';
import { ProfileModal } from '../Modal/ProfileModal';
import Announce from '../Announce/Announce';
Expand Down Expand Up @@ -200,9 +199,10 @@ export class ListRoomsButton extends React.Component<{}> {
deleteRoom = async (roomId: string) => {
if (this.context.user) {
const token = await this.context.user.getIdToken();
await axios.delete(
await fetch(
serverPath +
`/deleteRoom?uid=${this.context.user?.uid}&token=${token}&roomId=${roomId}`,
{ method: 'DELETE' },
);
this.setState({
rooms: this.state.rooms.filter((room) => room.roomId !== roomId),
Expand Down
5 changes: 2 additions & 3 deletions src/utils/generateName.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import axios from 'axios';
import { serverPath } from './index';

export async function generateName(): Promise<string> {
const response = await axios.get<string>(serverPath + '/generateName');
return response.data;
const response = await fetch(serverPath + '/generateName');
return response.json();
}

0 comments on commit 521aaf8

Please sign in to comment.