Skip to content

Commit

Permalink
Various bug fixes + mark activities read
Browse files Browse the repository at this point in the history
  • Loading branch information
micahlt committed Mar 18, 2024
1 parent 6d68d3e commit cfcd680
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 33 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ android {
applicationId "com.micahlindley.offsides"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 18
versionName "0.5.0"
versionCode 19
versionName "0.5.1"
}
signingConfigs {
debug {
Expand Down
Binary file modified android/app/release/app-release.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions android/app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 18,
"versionName": "0.5.0",
"versionCode": 19,
"versionName": "0.5.1",
"outputFile": "app-release.apk"
}
],
Expand Down
2 changes: 1 addition & 1 deletion docs/latest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"latestVersion": "0.5.0"
"latestVersion": "0.5.1"
}
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "offsides",
"version": "0.5.0",
"version": "0.5.1",
"private": true,
"scripts": {
"android": "react-native run-android",
Expand Down Expand Up @@ -32,7 +32,7 @@
"reanimated-color-picker": "^3.0.3",
"rn-emoji-keyboard": "^1.6.1",
"semver": "^7.6.0",
"sidechat.js": "^2.2.9",
"sidechat.js": "^2.3.3",
"timesago": "^1.0.1"
},
"devDependencies": {
Expand Down
61 changes: 54 additions & 7 deletions src/components/ActivityItem.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
import { useNavigation } from '@react-navigation/native';
import * as React from 'react';
import { View } from 'react-native';
import { Card, Icon, Text, useTheme } from 'react-native-paper';
import {
Card,
Icon,
Text,
TouchableRipple,
useTheme,
} from 'react-native-paper';
import timesago from 'timesago';
import { AppContext } from '../App';

function ActivityItem({ activity }) {
const {
appState: { API },
} = React.useContext(AppContext);
const nav = useNavigation();
const { colors } = useTheme();
const Handler = () => {
const [linkRoute, setLinkRoute] = React.useState('');
const [linkProps, setLinkProps] = React.useState({});
React.useEffect(() => {
setLinkRoute('Comments');
setLinkProps({ postID: activity.post_id });
}, [activity]);
const RenderedContent = () => {
if (activity.type == 'votes') {
return (
<Card.Content style={{ padding: 15 }}>
Expand All @@ -15,9 +34,10 @@ function ActivityItem({ activity }) {
size={20}></Icon>
<Text
variant="labelLarge"
style={{ marginLeft: 5, color: colors.primary }}>
style={{ marginLeft: 5, color: colors.primary, flex: 1 }}>
Votes
</Text>
<Text variant="bodySmall">{timesago(activity.timestamp)}</Text>
</View>
<Text variant="bodyMedium" style={{ color: colors.secondary }}>
{activity.text}
Expand All @@ -34,9 +54,27 @@ function ActivityItem({ activity }) {
size={20}></Icon>
<Text
variant="labelLarge"
style={{ marginLeft: 5, color: colors.primary }}>
style={{ marginLeft: 5, color: colors.primary, flex: 1 }}>
Popular
</Text>
<Text variant="bodySmall">{timesago(activity.timestamp)}</Text>
</View>
<Text variant="bodyMedium" style={{ color: colors.secondary }}>
{activity.text.replaceAll('📈 ', '')}
</Text>
</Card.Content>
);
} else if (activity.type == 'followed_post') {
return (
<Card.Content style={{ padding: 15 }}>
<View style={{ flexDirection: 'row', marginBottom: 5 }}>
<Icon source="forum" color={colors.primary} size={20}></Icon>
<Text
variant="labelLarge"
style={{ marginLeft: 5, color: colors.primary, flex: 1 }}>
Followed post
</Text>
<Text variant="bodySmall">{timesago(activity.timestamp)}</Text>
</View>
<Text variant="bodyMedium" style={{ color: colors.secondary }}>
{activity.text.replaceAll('📈 ', '')}
Expand All @@ -46,9 +84,18 @@ function ActivityItem({ activity }) {
}
};
return (
<Card mode="contained">
<Handler />
</Card>
<TouchableRipple
onPress={() => {
API.readActivity(activity.id).then(() => {
nav.navigate(linkRoute, linkProps);
});
}}
borderless={true}
style={{ borderRadius: 10 }}>
<Card mode="contained">
<RenderedContent />
</Card>
</TouchableRipple>
);
}

Expand Down
10 changes: 8 additions & 2 deletions src/components/CommentModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import useUniqueList from '../hooks/useUniqueList';
function CommentModal({ navigation, route }) {
/** @type {{postID: String, postObj: SidechatPostOrComment}} */
const { postID, postObj } = route.params;
const [localPost, setLocalPost] = React.useState(postObj);
const { appState } = React.useContext(AppContext);
const API = appState.API;
const { colors } = useTheme();
Expand All @@ -34,6 +35,11 @@ function CommentModal({ navigation, route }) {
);
const fetchComments = () => {
setLoadingComments(true);
if (!localPost && postID) {
API.getPost(postID).then(post => {
setLocalPost(post);
});
}
API.getPostComments(postID).then(res => {
setComments(res);
setLoadingComments(false);
Expand Down Expand Up @@ -61,7 +67,7 @@ function CommentModal({ navigation, route }) {
refreshing={loadingComments}
ListHeaderComponent={
<>
<Post post={postObj} commentView={true} />
<Post post={localPost} commentView={true} />
<Divider
style={{ width: '100%', marginTop: 20, marginBottom: 10 }}
bold={true}
Expand All @@ -83,7 +89,7 @@ function CommentModal({ navigation, route }) {
navigation.navigate('Writer', {
mode: 'comment',
postID: postID,
groupID: postObj.group.id,
groupID: localPost.group.id,
})
}
/>
Expand Down
10 changes: 6 additions & 4 deletions src/screens/HomeScreen.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@ function HomeScreen({ navigation, route }) {
setCurrentGroupId(appState.groupID);
}
});
React.useEffect(() => {
if (appState.groupColor) {
const t = createMaterial3Theme(appState.groupColor);
setCustomTheme(colorScheme == 'dark' ? t.dark : t.light);
}
}, [appState?.groupColor]);
React.useEffect(() => {
if (!loadingPosts) {
InteractionManager.runAfterInteractions(() => {
if (appState.groupColor) {
const t = createMaterial3Theme(appState.groupColor);
setCustomTheme(colorScheme == 'dark' ? t.dark : t.light);
}
if (appState.groupID && appState.userToken) {
setCurrentGroupId(currentGroupId);
setLoadingPosts(true);
Expand Down
8 changes: 5 additions & 3 deletions src/screens/MyProfileScreen.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function MyProfileScreen({ navigation }) {
</Card>
<Card style={{ flexGrow: 1 }}>
<Card.Title
title="Karma from Posts"
title="Post Karma"
titleVariant="labelLarge"
titleStyle={{ minHeight: 10 }}
/>
Expand All @@ -146,7 +146,9 @@ function MyProfileScreen({ navigation }) {
titleVariant="labelLarge"
titleStyle={{ minHeight: 10 }}
/>
{updates.activity_items?.items ? (
{updates.activity_items?.items &&
updates.activity_items?.items?.filter(i => !i.is_seen).length >
0 ? (
<Card.Content style={{ rowGap: 8 }}>
{updates.activity_items.items
.filter(i => !i.is_seen)
Expand All @@ -162,7 +164,7 @@ function MyProfileScreen({ navigation }) {
iconColor={colors.outline}
/>
<Text style={{ marginBottom: 20, color: colors.outline }}>
No activity yet.
No recent activity
</Text>
</Card.Content>
)}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8118,10 +8118,10 @@ side-channel@^1.0.4:
get-intrinsic "^1.2.4"
object-inspect "^1.13.1"

sidechat.js@^2.2.9:
version "2.2.9"
resolved "https://registry.npmjs.org/sidechat.js/-/sidechat.js-2.2.9.tgz"
integrity sha512-YjpS+FpbaZwlh6wbxSxlfGSiSrHhyBCkj2BebGN4+rVQH0EtHnYqrVyHJYkDCw85IPJv3VL2ps+hem6bIL2F2w==
sidechat.js@^2.3.3:
version "2.3.3"
resolved "https://registry.npmjs.org/sidechat.js/-/sidechat.js-2.3.3.tgz"
integrity sha512-7A9skzTUdo2oqED6KlePsXPP1WYx8HzmLCxEYzub6H7bunsf+8nNY3MP8YwjXIAm7SSW+A0s4a1ep4RDohnd3w==

signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3, signal-exit@^3.0.7:
version "3.0.7"
Expand Down

0 comments on commit cfcd680

Please sign in to comment.