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

Remove dependency on API v1 #30

Merged
merged 3 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const tagManagerArgs = {
gtmId: "GTM-MXQ4LWV",
};

export const ChangeLogContext = createContext();
export const ManagerContext = createContext();
export const ShowBraveContext = createContext();

// Change this to show BRAVE across website
Expand All @@ -42,17 +42,17 @@ const App = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [location]);

const [changeLogs, setChangeLogs] = useState({});
const [managerData, setManager] = useState({});

useEffect(() => {
fetch(process.env.REACT_APP_VANCED_LATEST_API_URL)
fetch("https://api.github.com/repos/YTVanced/VancedManager/releases/latest")
.then(res => res.json())
.then(data => setChangeLogs(data));
.then(data => setManager(data));
}, []);

return (
<ShowBraveContext.Provider value={showBrave}>
<ChangeLogContext.Provider value={changeLogs}>
<ManagerContext.Provider value={managerData}>
<ScrollReveal
ref={childRef}
children={() => (
Expand Down Expand Up @@ -84,7 +84,7 @@ const App = () => {
</Switch>
)}
/>
</ChangeLogContext.Provider>
</ManagerContext.Provider>
</ShowBraveContext.Provider>
);
};
Expand Down
4 changes: 4 additions & 0 deletions src/assets/scss/core/abstracts/_mixins.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Font Family
@mixin font-family($elem) {
@if (type-of($elem) == string) {
font-family: unquote(get-font-family($elem));
} @else {
font-family: initial;
}
}

// Font-size + Line-height + Kerning
Expand Down
7 changes: 2 additions & 5 deletions src/components/layout/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import PropTypes from "prop-types";
import classNames from "classnames";
import { Link } from "react-router-dom";
import Logo from "./partials/Logo";
import { ChangeLogContext } from "../../App";
import { Link as LinkScroll } from "react-scroll";
import { ManagerContext } from "../../App";

const propTypes = {
navPosition: PropTypes.string,
Expand Down Expand Up @@ -80,9 +79,7 @@ const Header = ({
className,
);

const ytVanced = useContext(ChangeLogContext)?.vanced;
const musicVanced = useContext(ChangeLogContext)?.music;
const vancedManagerAPKUrl = useContext(ChangeLogContext)?.manager?.url;
const vancedManagerAPKUrl = "https://github.com/YTVanced/VancedManager/releases/latest/download/manager.apk";

return (
<header {...props} className={classes}>
Expand Down
4 changes: 2 additions & 2 deletions src/components/layout/partials/FooterNav.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React, { useContext } from "react";
import classNames from "classnames";
import { Link } from "react-router-dom";
import { ChangeLogContext, ShowBraveContext } from "../../../App";
import { ManagerContext, ShowBraveContext } from "../../../App";
import { SiBrave, SiAdguard } from "react-icons/si";
import { ADGUARD, BRAVE } from "../../../constants/links";

const FooterNav = ({ className, ...props }) => {
const classes = classNames("footer-nav", className);

const vancedManagerAPKUrl = useContext(ChangeLogContext)?.manager?.url;
const vancedManagerAPKUrl = "https://github.com/YTVanced/VancedManager/releases/latest/download/manager.apk";
const showBrave = useContext(ShowBraveContext);

return (
Expand Down
43 changes: 33 additions & 10 deletions src/components/sections/ChangeLogs.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useContext } from "react";
import React, { useContext, useEffect, useState } from "react";
import classNames from "classnames";
import { SectionProps } from "../../utils/SectionProps";

import { ChangeLogContext } from "../../App";
import { ManagerContext } from "../../App";

const propTypes = {
...SectionProps.types,
Expand Down Expand Up @@ -37,13 +37,35 @@ const ChangeLogs = ({
bottomDivider && "has-bottom-divider",
);

const changeLogs = useContext(ChangeLogContext);
const [vancedData, setVanced] = useState({});
const [musicData, setMusic] = useState({});
const [microgData, setMicrog] = useState({});

useEffect(() => {
fetch("https://api.github.com/repos/YTVanced/Vanced/releases/latest")
.then(res => res.json())
.then(data => setVanced(data));
}, []);

useEffect(() => {
fetch("https://api.github.com/repos/YTVanced/VancedMusic/releases/latest")
.then(res => res.json())
.then(data => setMusic(data));
}, []);

useEffect(() => {
fetch("https://api.github.com/repos/YTVanced/VancedMicroG/releases/latest")
.then(res => res.json())
.then(data => setMicrog(data));
}, []);

const managerData = useContext(ManagerContext);

const changeLogsLoopData = [
{ name: "Vanced Manager", data: changeLogs?.manager },
{ name: "MicroG", data: changeLogs?.microg },
{ name: "YouTube™ Music Vanced", data: changeLogs?.music },
{ name: "YouTube™ Vanced", data: changeLogs?.vanced },
{ name: "Vanced Manager", data: managerData },
{ name: "MicroG", data: microgData },
{ name: "YouTube™ Music Vanced", data: musicData },
{ name: "YouTube™ Vanced", data: vancedData },
];

return (
Expand All @@ -68,21 +90,22 @@ const ChangeLogs = ({
<React.Fragment key={data.name}>
<h3>
{data.name}{" "}
<a href={data?.data?.url}>
<a href={data?.data?.html_url}>
<span
className="m-0 mb-32 reveal-from-bottom text-sm text-color-secondary"
data-reveal-delay="400"
>
(v{data?.data?.version})
({data?.data?.tag_name?.split('-')[0]})
</span>
</a>
</h3>
<p>Changelog:</p>
<ul>
{data?.data?.changelog.split("- ").map(point => {
{data?.data?.body?.split("- ").map(point => {
if (point) {
return <li key={point}>{point}</li>;
}
return point;
})}
</ul>
<hr />
Expand Down
8 changes: 4 additions & 4 deletions src/components/sections/Hero.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Button from "../elements/Button";
import getRandomQuotes from "../../utils/getRandomQuotes";
import Image from "../elements/Image";
import DownloadImg from "./../../assets/images/download.svg";
import { ChangeLogContext, ShowBraveContext } from "../../App";
import { ManagerContext, ShowBraveContext } from "../../App";

import { SiBrave, SiAdguard } from "react-icons/si";
import { ADGUARD, BRAVE } from "../../constants/links";
Expand Down Expand Up @@ -58,7 +58,7 @@ const Hero = ({
bottomDivider && "has-bottom-divider",
);

const vancedManager = useContext(ChangeLogContext)?.manager;
const vancedManager = useContext(ManagerContext);
const showBrave = useContext(ShowBraveContext);

return (
Expand All @@ -85,9 +85,9 @@ const Hero = ({
tag="a"
color="primary"
wideMobile
href={vancedManager?.url}
href="https://github.com/YTVanced/VancedManager/releases/latest/download/manager.apk"
>
Vanced Manager (v{vancedManager?.version})
Vanced Manager ({vancedManager?.tag_name?.split('-')[0]})
<Image
src={DownloadImg}
alt="Features tile icon 01"
Expand Down
4 changes: 0 additions & 4 deletions src/components/sections/HeroPc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Button from "../elements/Button";
import getRandomQuotes from "../../utils/getRandomQuotes";
import Image from "../elements/Image";
import DownloadImg from "./../../assets/images/download.svg";
import { ChangeLogContext, ShowBraveContext } from "../../App";

import { SiBrave, SiAdguard } from "react-icons/si";
import { ADGUARD, BRAVE } from "../../constants/links";
Expand Down Expand Up @@ -58,9 +57,6 @@ const Hero = ({
bottomDivider && "has-bottom-divider",
);

const vancedManager = useContext(ChangeLogContext)?.manager;
const showBrave = useContext(ShowBraveContext);

return (
<section {...props} className={outerClasses}>
<div className="container-sm">
Expand Down