Skip to content
Open
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
6 changes: 3 additions & 3 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "The Stanford Daily Mobile App",
"slug": "StanfordDaily",
"privacy": "public",
"version": "1.3.2",
"version": "1.4.0",
"platforms": [
"ios",
"android"
Expand All @@ -31,14 +31,14 @@
],
"ios": {
"bundleIdentifier": "com.Stanford.Daily.App",
"buildNumber": "14",
"buildNumber": "15",
"appStoreUrl": "https://itunes.apple.com/app/stanford-daily/id1341270063",
"supportsTablet": true
},
"android": {
"package": "com.Stanford.Daily.App",
"googleServicesFile": "./google-services.json",
"versionCode": 14,
"versionCode": 15,
"playStoreUrl": "https://play.google.com/store/apps/details?id=com.Stanford.Daily.App",
"permissions": [
"ACCESS_COARSE_LOCATION",
Expand Down
2 changes: 1 addition & 1 deletion app/HTML.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const renderers = {
else if (typeof htmlAttribs.class !== 'undefined' && htmlAttribs.class.includes("wp-block-embed__wrapper") && typeof passProps.rawChildren[0].attribs.title !== 'undefined' && passProps.rawChildren[0].attribs.title.includes("Spotify Embed")) { // hacky way of displaying Spotify players for podcasts
let uri = passProps.rawChildren[0].attribs.src;
return (
<WebView source={{ uri: uri }} style={{ height: 200, marginBottom: -32, marginTop: 8 }} />
<WebView source={{ uri: uri }} style={{ height: 200, marginBottom: -48, marginTop: 8 }} />
)
}
else {
Expand Down
3 changes: 2 additions & 1 deletion app/config/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const Tabs = createBottomTabNavigator({
inactiveTintColor: '#000000',
inactiveBackgroundColor: 'white',
activeBackgroundColor: 'white',
keyboardHidesTabBar: true,
labelStyle: {
fontFamily: "Open Sans", // FONTS.PT_SERIF
marginBottom: labelBottomMargin
Expand All @@ -98,7 +99,7 @@ export const Tabs = createBottomTabNavigator({
marginBottom: iphone_x ? -34 : 0
}
},
lazy: true
lazy: true,
});

const Root = createStackNavigator({
Expand Down
2 changes: 1 addition & 1 deletion app/helper/PushNotification.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function registerForPushNotificationsAsync() {
Permissions.NOTIFICATIONS
);
let finalStatus = existingStatus;

// only ask if permissions have not already been determined, because
// iOS won't necessarily prompt the user a second time.
if (existingStatus !== 'granted') {
Expand Down
45 changes: 31 additions & 14 deletions app/screens/FollowInfoStorage.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
import {AsyncStorage} from "react-native"
import { AsyncStorage, Linking, Alert } from "react-native"
import { STRINGS } from '../assets/constants.js'
import { Notifications } from "expo";
import * as Permissions from 'expo-permissions';

export async function getToken() {
const { status: existingStatus } = await Permissions.getAsync(
Permissions.NOTIFICATIONS
);
// if push notifications aren't on, alert user and give them the option to turn them on
if (existingStatus !== 'granted') { // code adapted from https://stackoverflow.com/questions/59980039/permissions-askasync-not-working-as-expected
Alert.alert(
"Please turn on notifications for this app in settings",
"",
[
{ text: "Cancel" },
{ text: "Settings", onPress: () => Linking.openURL("app-settings:") },
],
{ cancelable: false }
);
}

let token = await Notifications.getExpoPushTokenAsync();
if (__DEV__) {
console.log(token);
Expand Down Expand Up @@ -34,39 +51,39 @@ export async function followCategory(category_id) {
}

export async function unfollowCategory(category_id) {
let categories_followed = await getCategoriesFollowed();
let categories_followed = await getCategoriesFollowed();
var index = categories_followed.indexOf(category_id);
if (index !== -1) categories_followed.splice(index, 1); // remove category_id from list
await updateBackend();
return await AsyncStorage.setItem('categories_followed', JSON.stringify(categories_followed));
}

export async function followAuthor(author_id) {
let authors_followed = await getAuthorsFollowed();
let authors_followed = await getAuthorsFollowed();
authors_followed.push(author_id); // add author_id to authors_followed
await updateBackend();
return await AsyncStorage.setItem('authors_followed', JSON.stringify(authors_followed));
}

export async function unfollowAuthor(author_id) {
let authors_followed = await getAuthorsFollowed();
let authors_followed = await getAuthorsFollowed();
var index = authors_followed.indexOf(author_id);
if (index !== -1) authors_followed.splice(index, 1); // remove author_id from list
await updateBackend();
return await AsyncStorage.setItem('authors_followed', JSON.stringify(authors_followed));
}

export async function followLocation(location_id) {
let locations_followed = await getLocationsFollowed();
locations_followed.push(location_id);
let locations_followed = await getLocationsFollowed();
locations_followed.push(location_id);
await updateBackend();
return await AsyncStorage.setItem('locations_followed', JSON.stringify(locations_followed));
}

export async function unfollowLocation(location_id) {
let locations_followed = await getLocationsFollowed();
let locations_followed = await getLocationsFollowed();
var index = locations_followed.indexOf(location_id);
if (index !== -1) locations_followed.splice(index, 1);
if (index !== -1) locations_followed.splice(index, 1);
await updateBackend();
return await AsyncStorage.setItem('locations_followed', JSON.stringify(locations_followed));
}
Expand All @@ -93,14 +110,14 @@ export async function isFollowingLocation(location_id) {
}

export async function addNotificationSetting(notification_id) {
let notification_settings = await getNotificationSettings();
notification_settings.push(notification_id);
let notification_settings = await getNotificationSettings();
notification_settings.push(notification_id);
await updateBackend();
return await AsyncStorage.setItem('notification_settings', JSON.stringify(notification_settings));
}

export async function removeNotificationSetting(notification_id) {
let notification_settings = await getNotificationSettings();
let notification_settings = await getNotificationSettings();
var index = notification_settings.indexOf(notification_id);
if (index !== -1) notification_settings.splice(index, 1); // remove notification option from list
await updateBackend();
Expand All @@ -115,11 +132,11 @@ export async function isBeingNotified(notification_id) {
}

async function updateBackend() {
let response = await fetch(STRINGS.DAILY_URL + 'wp-json/tsd/v1/push-notification/users/' + await getToken(), {
let response = await fetch(STRINGS.DAILY_URL + 'wp-json/tsd/v1/push-notification/users/' + await getToken(), { // test notifications at "http://stanforddaily2.staging.wpengine.com/""
method: 'PUT',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
subscribing: {
Expand Down
13 changes: 7 additions & 6 deletions app/screens/Headlines.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default (props) => {
color: COLORS.BLACK,
marginLeft: MARGINS.ARTICLE_SIDES
}}>
Settings
Notification Settings
</Text>
</View>
</TouchableOpacity>
Expand Down Expand Up @@ -127,8 +127,9 @@ export default (props) => {
const {posts} = await getCategoryAsync([category.slug], pageNumber);
setArticles(posts);
}
setRefreshing(false);
})();
}, [pageNumber, category]);
}, [pageNumber, category, refreshing]);
return (
<Drawer
type={STRINGS.STATIC}
Expand All @@ -144,10 +145,10 @@ export default (props) => {
onCloseStart={() => StatusBar.setHidden(false)}
>
<View>
{/*<SettingsPage
<SettingsPage
visible={modalVisible}
setModalVisible={() => setModalVisible(!modalVisible)}
/>*/}
/>
</View>

<Header
Expand All @@ -163,9 +164,9 @@ export default (props) => {
ref={listRef}
removeClippedSubviews={false}
disableVirtualization={true}
// refreshing={refreshing}
refreshing={refreshing}
keyExtractor={item => `list-key-${item.id}`}
// onRefresh={() => setRefreshing(true)}
onRefresh={() => setRefreshing(true)}
// onEndReached={() => setPageNumber(pageNumber + 1)}
sections={[{ data: articles, key: `category-list-${pageNumber}-${category}` }]}
renderItem={_renderRow}
Expand Down
2 changes: 1 addition & 1 deletion app/screens/Post.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Post extends Component {
tagsStyles={{
p: { marginBottom: MARGINS.ARTICLE_SIDES },
a: { color: COLORS.CARDINAL },
strong: { fontFamily: FONTS.PT_SERIF_BOLD },
strong: { fontFamily: FONTS.PT_SERIF_BOLD },
em: { fontFamily: FONTS.PT_SERIF_ITALIC },
img: { marginHorizontal: -1 * MARGINS.ARTICLE_SIDES },
figure: { marginVertical: MARGINS.ARTICLE_SIDES },
Expand Down
Loading