Skip to content

Commit 81cb5ff

Browse files
Merge pull request #74 from Grad-Squad/cleanup/general
fix: final fixes
2 parents 10d6ee5 + 10b582f commit 81cb5ff

File tree

93 files changed

+22549
-29310
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+22549
-29310
lines changed

.github/workflows/cdRelease.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CD_Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
Continous_Deployment:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
- uses: actions/setup-node@v1
14+
with:
15+
node-version: 16
16+
17+
- uses: actions/cache@v2
18+
with:
19+
path: ~/.npm
20+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
21+
restore-keys: |
22+
${{ runner.os }}-node-
23+
24+
- run: npm ci
25+
26+
- name: Setup Expo and EAS
27+
uses: expo/expo-github-action@v7
28+
with:
29+
expo-version: 5.x
30+
eas-version: latest
31+
token: ${{ secrets.EXPO_TOKEN }}
32+
33+
- name: Build app and push app to play store
34+
run: eas build --non-interactive --auto-submit --platform android
35+
36+
- uses: sarisia/actions-status-discord@v1
37+
if: always()
38+
with:
39+
webhook: ${{ secrets.DISCORD_WEBHOOK }}

.github/workflows/integrate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
- uses: actions/setup-node@v1
1414
with:
15-
node-version: 14
15+
node-version: 16
1616

1717
- uses: actions/cache@v2
1818
with:

App.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ import { Colors } from 'styles';
1010
import ErrorSnackbarProvider from 'common/ErrorSnackbar/ErrorSnackbarProvider';
1111
import ReactQueryClient from 'components/ReactQueryClient/ReactQueryClient';
1212
import { Provider as ReduxProvider } from 'react-redux';
13-
import { Platform, UIManager } from 'react-native';
13+
import { LogBox, Platform, UIManager } from 'react-native';
1414
import { LocalizationProvider } from './localization';
1515
import initStyles from './styles/init';
1616
import RootNavigator from './navigation/RootNavigator';
1717
import store from './globalStore/store';
1818

19+
LogBox.ignoreLogs(['Setting a timer']);
20+
1921
const theme = {
2022
...DefaultTheme,
2123
colors: {
@@ -44,7 +46,7 @@ function App() {
4446
Sentry.init({
4547
dsn: process.env.SENTRY_DSN,
4648
enableInExpoDevelopment: true,
47-
enableNative: false,
49+
// enableNative: false,
4850
debug: true, // TODO set to false in production
4951
});
5052

__test__/components/ExpandedPost/ExpandedPostContent/__snapshots__/AuthorInfo.spec.jsx.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ exports[`should match snapshot when profilePicture={ uri: 'https://picsum.photos
2828
}
2929
>
3030
<Image
31+
resizeMode="cover"
3132
source={
3233
Object {
3334
"uri": "https://picsum.photos/200/300",
3435
}
3536
}
3637
style={
3738
Object {
39+
"alignSelf": "center",
3840
"borderRadius": 50,
3941
"height": 50,
4042
"width": 50,
@@ -109,9 +111,11 @@ exports[`should match snapshot when profilePicture=null 1`] = `
109111
}
110112
>
111113
<Image
114+
resizeMode="cover"
112115
source={1}
113116
style={
114117
Object {
118+
"alignSelf": "center",
115119
"borderRadius": 50,
116120
"height": 50,
117121
"width": 50,

__test__/setup.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
jest.mock('react-native/Libraries/Animated/src/NativeAnimatedHelper');
1+
import mockAsyncStorage from '@react-native-async-storage/async-storage/jest/async-storage-mock';
2+
3+
jest.mock('@react-native-async-storage/async-storage', () => mockAsyncStorage);
24
jest.mock('@react-navigation/native', () => {
35
const actualNav = jest.requireActual('@react-navigation/native');
46
return {

api/AxiosProvider.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { useLocalization } from 'localization/LocalizationProvider';
1616
import { useNetInfo } from '@react-native-community/netinfo';
1717
import ScreenNames from 'navigation/ScreenNames';
1818
import { Alert } from 'react-native';
19+
import LoadingIndicator from 'common/LoadingIndicator';
1920
import unauthorizedRedirectBlacklist from './unauthorizedRedirectBlacklist';
2021
import endpoints from './endpoints/endpoints';
2122

@@ -30,14 +31,22 @@ const AxiosProvider = ({ navigationRef, children }) => {
3031
const { t } = useLocalization();
3132

3233
const [accessToken, setAccessToken] = useState('');
34+
const [hasCheckedAccessToken, SetHasCheckedAccessToken] = useState(false);
3335
const [refreshToken, setRefreshToken] = useState('');
3436
const [onAccessTokenChangeCallbacks, setOnAccessTokenChangeCallbacks] =
3537
useState([]);
3638

3739
useEffect(() => {
3840
(async () => {
39-
setAccessToken(await getItemFromStorage(localStorageKeys.access_token));
40-
setRefreshToken(await getItemFromStorage(localStorageKeys.refresh_token));
41+
const newAccessToken = await getItemFromStorage(
42+
localStorageKeys.access_token
43+
);
44+
const newRefreshToken = await getItemFromStorage(
45+
localStorageKeys.refresh_token
46+
);
47+
setAccessToken(newAccessToken);
48+
setRefreshToken(newRefreshToken);
49+
SetHasCheckedAccessToken(true);
4150
})();
4251
}, []);
4352

@@ -82,7 +91,7 @@ const AxiosProvider = ({ navigationRef, children }) => {
8291
index: 0,
8392
routes: [{ name: ScreenNames.LOGIN }],
8493
});
85-
Alert.alert('Sorry, You have to login again');
94+
Alert.alert(t('Sorry, You have to log in again'));
8695
}
8796
} else {
8897
const refreshData = await newAxios.post(endpoints.auth.refresh, {
@@ -140,9 +149,14 @@ const AxiosProvider = ({ navigationRef, children }) => {
140149
addOnAccessTokenChangeCallback: (callback) => {
141150
setOnAccessTokenChangeCallbacks((prev) => [...prev, callback]);
142151
},
152+
isLoggedIn: !!accessToken,
143153
}}
144154
>
145-
{children}
155+
{hasCheckedAccessToken ? (
156+
children
157+
) : (
158+
<LoadingIndicator fullScreen size="large" />
159+
)}
146160
</AxiosContext.Provider>
147161
);
148162
};

api/endpoints/auth.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useMutation } from 'react-query';
33
import { formatString } from 'utility';
44
import endpoints from './endpoints';
55

6-
const onSuccessUpdateTokens =
6+
export const onSuccessUpdateTokens =
77
(
88
updateAccessToken,
99
updateRefreshToken,
@@ -126,12 +126,7 @@ export const useAPIRefreshToken = (mutationConfig) => {
126126
};
127127

128128
export const useAPIRegister = (mutationConfig) => {
129-
const {
130-
axios,
131-
updateAccessToken,
132-
updateRefreshToken,
133-
addOnAccessTokenChangeCallback,
134-
} = useAxios();
129+
const { axios } = useAxios();
135130
return useMutation(
136131
async ({ email, password, name }) => {
137132
const { data } = await axios.post(endpoints.auth.register, {
@@ -149,12 +144,6 @@ export const useAPIRegister = (mutationConfig) => {
149144
},
150145
{
151146
...mutationConfig,
152-
onSuccess: onSuccessUpdateTokens(
153-
updateAccessToken,
154-
updateRefreshToken,
155-
addOnAccessTokenChangeCallback,
156-
mutationConfig
157-
),
158147
}
159148
);
160149
};

api/endpoints/endpoints.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default Object.freeze({
1313
profileById: '/profiles/{0}',
1414
update: '/profiles/{0}',
1515
followers: '/profiles/{0}/followers',
16+
followed: '/profiles/me/followed',
1617
postsByProfileId: '/profiles/{0}/posts',
1718
followProfile: '/profiles/{0}/follow',
1819
AddPostToBookmark: '/profiles/{0}/bookmarks/add/{1}',

api/endpoints/profile.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,24 @@ export const useAPIGetProfileFollowers = (profileId) => {
2626
);
2727
};
2828

29+
export const profilesFollowedKey = 'profilesFollowed';
30+
export const useAPIGetProfilesFollowed = () => {
31+
const { axios } = useAxios();
32+
return useInfiniteQuery(
33+
profilesFollowedKey,
34+
async ({ pageParam = 1 }) => {
35+
const { data } = await axios.get(endpoints.profile.followed, {
36+
params: {
37+
page: pageParam,
38+
limit: 10,
39+
},
40+
});
41+
return data;
42+
},
43+
{ getNextPageParam: (lastPage) => lastPage.nextPage }
44+
);
45+
};
46+
2947
export const profileByIdQueryKey = (profileId) => ['profile by id', profileId];
3048
export const useAPIGetProfileById = (profileId, options) => {
3149
const { axios } = useAxios();

api/endpoints/ratings.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ export const useAPIUnvotePost = (mutationConfig) =>{
4141

4242
export const useAPIUpvoteComment = (mutationConfig) =>{
4343
const { axios } = useAxios();
44-
return useMutation( async ({commentId, ratingId}) => {
44+
return useMutation( async ({postId, ratingId}) => {
4545
const {
4646
data,
47-
} = await axios.patch(formatString(endpoints.comments.ratings,commentId,ratingId), {
47+
} = await axios.patch(formatString(endpoints.comments.ratings,postId,ratingId), {
4848
type: 'upvoted',
4949
});
5050
return data;
@@ -53,10 +53,10 @@ export const useAPIUpvoteComment = (mutationConfig) =>{
5353

5454
export const useAPIDownvoteComment = (mutationConfig) =>{
5555
const { axios } = useAxios();
56-
return useMutation( async ({commentId, ratingId}) => {
56+
return useMutation( async ({postId, ratingId}) => {
5757
const {
5858
data,
59-
} = await axios.patch(formatString(endpoints.comments.ratings,commentId,ratingId), {
59+
} = await axios.patch(formatString(endpoints.comments.ratings,postId,ratingId), {
6060
type: 'downvoted',
6161
});
6262
return data;
@@ -65,10 +65,10 @@ export const useAPIDownvoteComment = (mutationConfig) =>{
6565

6666
export const useAPIUnvoteComment = (mutationConfig) =>{
6767
const { axios } = useAxios();
68-
return useMutation( async ({commentId, ratingId}) => {
68+
return useMutation( async ({postId, ratingId}) => {
6969
const {
7070
data,
71-
} = await axios.patch(formatString(endpoints.comments.ratings,commentId,ratingId), {
71+
} = await axios.patch(formatString(endpoints.comments.ratings,postId,ratingId), {
7272
type: 'none',
7373
});
7474
return data;

0 commit comments

Comments
 (0)