Skip to content

Commit

Permalink
Small code re-formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
mambans committed Oct 4, 2020
1 parent 46a3763 commit 9a2d684
Show file tree
Hide file tree
Showing 18 changed files with 117 additions and 211 deletions.
3 changes: 2 additions & 1 deletion frontend/src/components/alert/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default (data) => {
} = data?.data || data;
const [show, setShow] = useState(Boolean(title || message));

if (show && Boolean(manualShow))
if (show && Boolean(manualShow)) {
return (
<StyledAlert
variant={type}
Expand All @@ -37,6 +37,7 @@ export default (data) => {
{children}
</StyledAlert>
);
}

return null;
};
39 changes: 16 additions & 23 deletions frontend/src/components/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ import useEventListenerMemo from '../../hooks/useEventListenerMemo';
export default () => {
return (
<ThemeProvider>
<NavigationProvider>
<AccountProvider>
<AccountProvider>
<NavigationProvider>
<NotificationsProvider>
<FeedsProvider>
<FooterProvider>
<App />
</FooterProvider>
</FeedsProvider>
</NotificationsProvider>
</AccountProvider>
</NavigationProvider>
</NavigationProvider>
</AccountProvider>
</ThemeProvider>
);
};
Expand All @@ -44,26 +44,19 @@ const App = () => {

useEventListenerMemo('message', receiveMessage, window, true, { capture: false });

useEffect(() => {
SetStartupTheme(themesArray);
}, [themesArray]);
useEffect(() => SetStartupTheme(themesArray), [themesArray]);

function receiveMessage(event) {
if (
event.origin.startsWith('https://aiofeed.com') &&
typeof event.data === 'object' &&
event.data.token &&
event.data.service
) {
if (event.data.service === 'twitch') {
setTwitchToken(event.data.token);
setRefreshToken(event.data.refresh_token);
setTwitchUsername(event.data.username);
setTwitchProfileImg(event.data.profileImg);
} else if (event.data.service === 'youtube') {
if (event.data.token) setYoutubeToken(event.data.token);
if (event.data.username) setYoutubeUsername(event.data.username);
if (event.data.profileImg) setYoutubeProfileImg(event.data.profileImg);
function receiveMessage(e) {
if (e.origin.startsWith('https://aiofeed.com') && e.data?.token && e.data?.service) {
if (e.data.service === 'twitch') {
setTwitchToken(e.data.token);
setRefreshToken(e.data.refresh_token);
setTwitchUsername(e.data.username);
setTwitchProfileImg(e.data.profileImg);
} else if (e.data.service === 'youtube') {
if (e.data.token) setYoutubeToken(e.data.token);
if (e.data.username) setYoutubeUsername(e.data.username);
if (e.data.profileImg) setYoutubeProfileImg(e.data.profileImg);
}
}
}
Expand Down
32 changes: 0 additions & 32 deletions frontend/src/components/app/App.scss

This file was deleted.

4 changes: 1 addition & 3 deletions frontend/src/components/auth/TwitchAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ function TwitchAuth() {
const [error, setError] = useState();

const initiateAuth = useCallback(async () => {
async function generateOrginState() {
return uniqid();
}
const generateOrginState = async () => uniqid();

const orginState = await generateOrginState();
AddCookie('Twitch-myState', orginState);
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/components/auth/YoutubeAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ function YoutubeAuth() {
const [error, setError] = useState();

const initiateAuth = useCallback(async () => {
async function generateOrginState() {
return uniqid();
}
const generateOrginState = async () => uniqid();

const orginState = await generateOrginState();

Expand Down
11 changes: 5 additions & 6 deletions frontend/src/components/changeLogs/Alert.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useState, useEffect } from "react";
import styled from "styled-components";
import { Alert } from "react-bootstrap";
import React, { useState, useEffect } from 'react';
import styled from 'styled-components';
import { Alert } from 'react-bootstrap';

import { AddCookie, getCookie } from "../../util/Utils";
import { AddCookie, getCookie } from '../../util/Utils';

const StyledAlert = styled(Alert)`
text-align: center;
Expand All @@ -28,7 +28,6 @@ export default ({ AlertName }) => {
Something happended, do that thing.
</StyledAlert>
);
} else {
return "";
}
return '';
};
12 changes: 4 additions & 8 deletions frontend/src/components/changeLogs/FetchRepoReleases.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import axios from "axios";
import axios from 'axios';

export default async () => {
return await axios
.get("https://api.github.com/repos/mambans/aiofeed/releases")
.then((res) => {
return res.data;
})
.catch((error) => {
console.error(error);
});
.get('https://api.github.com/repos/mambans/aiofeed/releases')
.then((res) => res.data)
.catch((error) => console.error(error));
};
10 changes: 3 additions & 7 deletions frontend/src/components/changeLogs/FetchRepoTagInfo.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import axios from "axios";
import axios from 'axios';

export default async (name) => {
return await axios
.get(`https://api.github.com/repos/mambans/aiofeed/releases/tags/${name}`)
.then((res) => {
return res.data;
})
.catch((error) => {
console.error(error);
});
.then((res) => res.data)
.catch((error) => console.error(error));
};
12 changes: 4 additions & 8 deletions frontend/src/components/changeLogs/FetchRepoTags.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import axios from "axios";
import axios from 'axios';

export default async () => {
return await axios
.get("https://api.github.com/repos/mambans/aiofeed/tags")
.then((res) => {
return res.data;
})
.catch((error) => {
console.error(error);
});
.get('https://api.github.com/repos/mambans/aiofeed/tags')
.then((res) => res.data)
.catch((error) => console.error(error));
};
17 changes: 6 additions & 11 deletions frontend/src/components/changeLogs/ListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,22 @@ const List = {
export default ({ name, body, published_at, showInfo, children }) => {
const [info, setInfo] = useState({ loading: false, data: null });
const [showFullMessage, setShowFullMessage] = useState(false);
const additionsKeywords = useMemo(() => ['added', 'add', 'fix', 'fixed'], []);
const deletionsKeywords = useMemo(() => ['removed', 'remove', 'deleted', 'delete'], []);
const additionsKeywords = useMemo(() => ['added', 'fixed'], []);
const deletionsKeywords = useMemo(() => ['removed', 'deleted'], []);
const changesKeywords = useMemo(
() => [
'changed',
'change',
'refactored',
'refactor',
'restyled',
'moved',
'move',
'renamed',
'rename',
'changes',
'improved',
'increased',
'fixed/added',
'added/fixed',
'split',
'extracted',
],
[]
);
Expand Down Expand Up @@ -159,11 +158,7 @@ export default ({ name, body, published_at, showInfo, children }) => {
}
}, [body, published_at, additionsKeywords, deletionsKeywords, changesKeywords]);

useEffect(() => {
if (showInfo) {
handleClick();
}
}, [showInfo, handleClick]);
useEffect(() => showInfo && handleClick(), [showInfo, handleClick]);

return (
<List.Container>
Expand Down
58 changes: 28 additions & 30 deletions frontend/src/components/changeLogs/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import React, { useEffect, useState } from "react";
import styles from "./ChangeLogs.module.scss";
import React, { useEffect, useState } from 'react';
import styles from './ChangeLogs.module.scss';

import { Modal } from "react-bootstrap";
import FetchRepoReleases from "./FetchRepoReleases";
import Alert from "./Alert";
import ListItem from "./ListItem";
import { Modal } from 'react-bootstrap';
import FetchRepoReleases from './FetchRepoReleases';
import Alert from './Alert';
import ListItem from './ListItem';

export default ({ NewAlertName }) => {
const [repo, setRepo] = useState();

useEffect(() => {
(async () => {
await FetchRepoReleases().then((tags) => {
setRepo({ tags: tags });
});
await FetchRepoReleases().then((tags) => setRepo({ tags: tags }));
})();
}, []);

Expand All @@ -24,27 +22,27 @@ export default ({ NewAlertName }) => {
</Modal.Header>
<Modal.Body bsPrefix={styles.ulContainer} as='div'>
<Alert AlertName={NewAlertName} />
{repo &&
repo.tags.slice(0, 1).map((tag) => {
return (
<ListItem
name={tag.name}
key={tag.node_id}
body={tag.body}
published_at={tag.published_at}
showInfo></ListItem>
);
})}
{repo &&
repo.tags.slice(1, 15).map((tag) => {
return (
<ListItem
name={tag.name}
key={tag.node_id}
body={tag.body}
published_at={tag.published_at}></ListItem>
);
})}
{repo?.tags.slice(0, 1).map((tag) => {
return (
<ListItem
name={tag.name}
key={tag.node_id}
body={tag.body}
published_at={tag.published_at}
showInfo
></ListItem>
);
})}
{repo?.tags.slice(1, 15).map((tag) => {
return (
<ListItem
name={tag.name}
key={tag.node_id}
body={tag.body}
published_at={tag.published_at}
></ListItem>
);
})}
</Modal.Body>
</>
);
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/favorites/AddVideoButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export default ({ videoId_p, style = {}, size, disablepreview = () => {} }) => {
e.stopPropagation();
clearTimeout(fadeOutTimer.current);
clearTimeout(openTimer.current);
// disablepreview();
openTimer.current = setTimeout(() => setOpen(true), 250);
setTimeout(() => disablepreview(), 0);
};
Expand Down
8 changes: 2 additions & 6 deletions frontend/src/components/favorites/DeleteListBtn.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@ export default ({ list, setLists }) => {
username: getCookie('AioFeed_AccountName'),
listName: list.name,
})
.then((res) => {
console.log('res', res);
})
.catch((e) => {
console.error(e);
});
.then((res) => console.log('res', res))
.catch((e) => console.error(e));
};

return (
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/components/favorites/FavoritesContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ export const FavoritesProvider = ({ children }) => {
delete res.data.Item?.Username;
return res.data.Item;
})
.catch((e) => {
console.error(e);
});
.catch((e) => console.error(e));

setLists(Lists);
};
Expand Down
Loading

0 comments on commit 9a2d684

Please sign in to comment.