Skip to content
This repository has been archived by the owner on Oct 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2 from Asiern/beta
Browse files Browse the repository at this point in the history
Beta1.0.10
  • Loading branch information
Asiern authored Oct 11, 2020
2 parents 41c9e30 + 79b324e commit aa38ac6
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 90 deletions.
18 changes: 18 additions & 0 deletions Notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# Version 1.0.10 Notes

## What's new?

## Fixes

- Fixed: Notifications
- Fixed: Security issues.

## Known issues

- App not reloading when logging out.
- Runs with multiple runners not displaying properly.
- Japanese users not displaying.
- OS forced darkmode breaks `UserHeader.js` colors.

---

# Version 1.0.9 Notes

## What's new?
Expand Down
6 changes: 3 additions & 3 deletions Source/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"expo": {
"name": "SpeedrunHub",
"slug": "speedruncomapp",
"platforms": ["ios", "android", "web"],
"version": "1.0.9",
"platforms": ["ios", "android"],
"version": "1.0.10",
"orientation": "portrait",
"icon": "./app/assets/trophy.png",

Expand All @@ -23,7 +23,7 @@
"githubUrl": "https://github.com/Asiern/SpeedrunHub",
"android": {
"package": "com.asiern.speedrun",
"versionCode": 9,
"versionCode": 10,
"permissions" : []
}
}
Expand Down
73 changes: 4 additions & 69 deletions Source/app/components/NotificationBar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import React,{useEffect} from "react";
import {
View,
StyleSheet,
Expand All @@ -8,74 +8,10 @@ import {
TouchableOpacity,
} from "react-native";
import NotificationCard from "./NotificationCard";
import { ActivityIndicator } from "react-native-paper";

import colors from "../config/colors";

const NotificationBar = (props) => {
const [data, setData] = useState(null);
const [loading, setloading] = useState(true);
const [error, seterror] = useState(false);
useEffect(() => {
let mounted = true;

try {
if (loading) {
var url = "https://www.speedrun.com/api/v1/notifications";
var xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.setRequestHeader("Host", "www.speedrun.com");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("X-API-Key", props.APIKey);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && mounted) {
response = JSON.parse(xhr.responseText);
setData(response.data);
setloading(false);
}
};
xhr.send();
}
} catch (error) {
seterror(true);
}
return function cleanup() {
mounted = false;
};
}, [data, loading]);
if (loading) {
return <ActivityIndicator />;
} else if (error) {
return <Text>Something went wrong</Text>;
} else if (data == undefined) {
return (
<View style={styles.container}>
<View style={styles.headerConatiner}>
<View>
<Text style={styles.headertext}>Notifications</Text>
</View>
</View>
{props.APIKey == null ? (
<NotificationCard
width={props.width}
text={
"API-Key not found, Please login using your API-Key if you want to receive notifications"
}
backgroundColor={colors.white}
color={colors.darkgrey}
/>
) : (
<NotificationCard
width={props.width}
text={
"No notifications were found. Make sure your API-Key and your Speedrun.com notifications settings are correct. Otherwise try restarting the app."
}
backgroundColor={colors.primary}
color={colors.white}
/>
)}
</View>
);
} else {
return (
<View style={styles.container}>
<View style={styles.headerConatiner}>
Expand All @@ -85,7 +21,7 @@ const NotificationBar = (props) => {
<TouchableOpacity
onPress={() =>
props.navigation.navigate("Notifications", {
data: data,
data: props.data,
})
}
>
Expand All @@ -95,7 +31,7 @@ const NotificationBar = (props) => {

<FlatList
keyExtractor={(item) => item.id}
data={data}
data={props.data}
pagingEnabled
renderItem={({ item }) => (
<View>
Expand Down Expand Up @@ -126,7 +62,6 @@ const NotificationBar = (props) => {
</View>
);
}
};

const styles = StyleSheet.create({
container: {
Expand Down
4 changes: 2 additions & 2 deletions Source/app/config/Themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export const theme = {
PRIMARY_BACKGROUND: "#fff",
SECONDARY_BACKGROUND: "#ededed",
PRIMARY_TEXT: "#242c37",
PRIMARY_ACCENT: "#e57373",
PRIMARY_ACCENT: "#FF8A65",
INACTIVE: "#242c37",
STATUS_BAR_STYILE: "dark-content",
};
Expand All @@ -12,7 +12,7 @@ export const lightTheme = {
PRIMARY_BACKGROUND: "#fff",
SECONDARY_BACKGROUND: "#ededed",
PRIMARY_TEXT: "#242c37",
PRIMARY_ACCENT: "#e57373",
PRIMARY_ACCENT: "#FF8A65",
INACTIVE: "#242c37",
STATUS_BAR_STYILE: "dark-content",
};
Expand Down
39 changes: 23 additions & 16 deletions Source/app/screens/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { useSelector } from "react-redux";
import MyGames from "../components/MyGames";
import UserHeader from "../components/UserHeader";
import NotificationBar from "../components/NotificationBar";
import NotificationCard from "../components/NotificationCard";
import colors from "../config/colors";

const { width } = Dimensions.get("screen");
Expand All @@ -22,28 +21,35 @@ export default function Home(props) {

const [username, setUsername] = useState("Guest");
const [userid, setUserid] = useState("");
const [APIKey, setAPIKey] = useState("");
const [games, setGames] = useState([]);

useEffect(() => {
let mounted = true;

if (mounted) {
fetchData();
}
return function cleanup() {
mounted = false;
};
}, []);
const [notifications,setNotifications]= useState(null);
const [APIKey,setAPIKey] = useState(props.APIKey);

function fetchNotifications(){
var url = "https://www.speedrun.com/api/v1/notifications";
var xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.setRequestHeader("Host", "www.speedrun.com");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("X-API-Key", APIKey);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
response = JSON.parse(xhr.responseText);
setNotifications(response.data);
}
};
xhr.send();
}
async function fetchData() {
fetchNotifications();
const GAMES = await AsyncStorage.getItem("@MyGames");
const username = await AsyncStorage.getItem("@user");
const userid = await AsyncStorage.getItem("@userid");
const APIKey = await AsyncStorage.getItem("@API-Key");
const key = await AsyncStorage.getItem("@API-Key");
setAPIKey(key);
setGames(JSON.parse(GAMES));
setUsername(username);
setUserid(userid);
setAPIKey(APIKey);
}
useFocusEffect(
React.useCallback(() => {
Expand All @@ -66,8 +72,9 @@ export default function Home(props) {
</View>
<NotificationBar
width={width}
APIKey={APIKey}
APIKey={props.APIKey}
navigation={navigation}
data={notifications}
/>
<Text style={styles.headertext}>My Games</Text>
<MyGames data={games} navigation={navigation} />
Expand Down

0 comments on commit aa38ac6

Please sign in to comment.