aboutsummaryrefslogtreecommitdiff
path: root/src/store/initialStates.ts
diff options
context:
space:
mode:
authorAshm Walia <40498934+ashmgarv@users.noreply.github.com>2020-12-04 08:50:24 -0800
committerGitHub <noreply@github.com>2020-12-04 11:50:24 -0500
commit0fd892ad288f2e1eaaa4fdf5e1fd6f15dbd45860 (patch)
treed7d53d94c6c4026ac9b325508ebce4706d412ac4 /src/store/initialStates.ts
parentf620102190629e0b6f180d3ce056d850b1db5aaa (diff)
[TMA - 398 AND TMA-430] Replace Providers with Redux Store (#125)
* First * WIP * Thunk * Some more comments * sc * recent searches and follounfollow * Edit profile dummy * Block / unblock and some cleanup * Replace auth provider * Sc * Delete AP after rebase * Discover users * Cleanup * More cleanup * Replace profile provider * Fixed build failure * Fixed a bug reported * Prevent app crash when backend server is down
Diffstat (limited to 'src/store/initialStates.ts')
-rw-r--r--src/store/initialStates.ts95
1 files changed, 95 insertions, 0 deletions
diff --git a/src/store/initialStates.ts b/src/store/initialStates.ts
new file mode 100644
index 00000000..4087b97c
--- /dev/null
+++ b/src/store/initialStates.ts
@@ -0,0 +1,95 @@
+import {MomentType} from 'src/types';
+import {
+ ProfileType,
+ SocialAccountType,
+ ProfilePreviewType,
+ ScreenType,
+ UserXType,
+ UserType,
+} from '../types';
+
+export const NO_PROFILE: ProfileType = {
+ biography: '',
+ website: '',
+ name: '',
+ gender: '',
+ birthday: undefined,
+};
+
+export const EMPTY_MOMENTS_LIST = <MomentType[]>[];
+
+export const NO_USER: UserType = {
+ userId: '',
+ username: '',
+};
+
+export const EMPTY_PROFILE_PREVIEW_LIST = <ProfilePreviewType[]>[];
+
+export const NO_USER_DATA = {
+ user: <UserType>NO_USER,
+ profile: <ProfileType>NO_PROFILE,
+ avatar: <string | null>'',
+ cover: <string | null>'',
+};
+
+export const NO_FOLLOW_DATA = {
+ followers: EMPTY_PROFILE_PREVIEW_LIST,
+ following: EMPTY_PROFILE_PREVIEW_LIST,
+};
+
+export const NO_MOMENTS = {
+ moments: EMPTY_MOMENTS_LIST,
+};
+
+export const NO_SOCIAL_ACCOUNTS: Record<string, SocialAccountType> = {
+ Instagram: {posts: []},
+ Facebook: {posts: []},
+ Twitter: {posts: []},
+};
+
+export const NO_TAGG_USERS = {
+ recentSearches: EMPTY_PROFILE_PREVIEW_LIST,
+ taggUsers: EMPTY_PROFILE_PREVIEW_LIST,
+};
+
+export const NO_SOCIALS = {
+ socialAccounts: NO_SOCIAL_ACCOUNTS,
+};
+
+export const NO_BLOCKED_USERS = {
+ blockedUsers: EMPTY_PROFILE_PREVIEW_LIST,
+};
+
+/**
+ * The dummy userId and username serve the purpose of preventing app crash
+ * For instance, if it may happen that data in our store is not loaded yet for the userXId being visited.
+ * Then we will set the userXId / username to this dummy username / userid
+ */
+export const DUMMY_USERID = 'ID-1234-567';
+export const DUMMY_USERNAME = 'tagg_userX';
+
+export const EMPTY_USER_X = <UserXType>{
+ followers: EMPTY_PROFILE_PREVIEW_LIST,
+ following: EMPTY_PROFILE_PREVIEW_LIST,
+ moments: EMPTY_MOMENTS_LIST,
+ socialAccounts: NO_SOCIAL_ACCOUNTS,
+ user: NO_USER,
+ profile: NO_PROFILE,
+ avatar: '',
+ cover: '',
+};
+
+/**
+ * A dummy userX to always be there in out initial app state
+ */
+export const EMPTY_USERX_LIST = <Record<string, UserXType>>{
+ [DUMMY_USERID]: EMPTY_USER_X,
+};
+
+export const EMPTY_SCREEN_TO_USERS_LIST: Record<
+ ScreenType,
+ Record<string, UserXType>
+> = {
+ [ScreenType.Profile]: EMPTY_USERX_LIST,
+ [ScreenType.Search]: EMPTY_USERX_LIST,
+};