Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
merge w master
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenzo committed Sep 12, 2019
1 parent b0f9f2b commit 9bd2b2c
Show file tree
Hide file tree
Showing 33 changed files with 138 additions and 1,800 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -4,7 +4,7 @@
"description": "3box dapp",
"private": true,
"dependencies": {
"3box": "^1.10.5",
"3box": "^1.10.9",
"3box-activity": "0.0.9",
"@babel/polyfill": "^7.4.4",
"abi-decoder": "^2.0.1",
Expand All @@ -23,7 +23,7 @@
"ipfs-log": "^4.3.5",
"lodash.clonedeep": "^4.5.0",
"nacl-did": "^0.4.0",
"profile-hover": "^1.0.2",
"profile-hover": "^1.1.0",
"prop-types": "^15.6.1",
"query-string": "^6.8.1",
"react": "^16.8.6",
Expand Down
19 changes: 9 additions & 10 deletions src/App.jsx
Expand Up @@ -50,8 +50,8 @@ const {
getVerifiedPublicTwitter,
getVerifiedPrivateEmail,
getActivity,
// getMyFollowing,
// getPublicFollowing,
getMyFollowing,
getPublicFollowing,
saveFollowing,
} = actions.profile;

Expand Down Expand Up @@ -112,7 +112,7 @@ class App extends Component {
this.directSignIn(queryParams.wallet);
} else if (onProfilePage) { // Lands on profile page
const userEth = window.localStorage.getItem('userEthAddress');
// if (userEth) this.props.getPublicFollowing(userEth);
if (userEth) this.props.getPublicFollowing(userEth);
if (isProtectedRoute) history.push(`/${firstParam}`);
}
} catch (err) {
Expand All @@ -128,7 +128,6 @@ class App extends Component {
const isNewPath = nextProps.location.pathname !== location.pathname;

if (queryParams.wallet && isNewPath) this.directSignIn(queryParams.wallet, nextProps);

if (onSyncDoneToTrigger) { // get profile data again only when onSyncDone
store.dispatch({ // end onSyncDone animation
type: 'UI_APP_SYNC',
Expand Down Expand Up @@ -170,7 +169,7 @@ class App extends Component {
this.props.getMyProfileValue('public', 'emoji'); // eslint-disable-line
this.props.getMyProfileValue('private', 'birthday'); // eslint-disable-line

// this.props.getMyFollowing(); // eslint-disable-line
this.props.getMyFollowing(); // eslint-disable-line

await this.props.getCollectibles(currentAddress); // eslint-disable-line
await this.props.convert3BoxToSpaces(); // eslint-disable-line
Expand Down Expand Up @@ -298,7 +297,7 @@ class App extends Component {
/>
)}

{(!isMyProfilePath && isLoggedIn) && <Nav />}
{(!isMyProfilePath && isLoggedIn) && <Nav handleSignInUp={this.handleSignInUp} />}

<AppModals
isFetchingThreeBox={isFetchingThreeBox}
Expand Down Expand Up @@ -366,8 +365,8 @@ App.propTypes = {
injectWeb3: PropTypes.func.isRequired,
getMyProfileValue: PropTypes.func.isRequired,
checkMobileWeb3: PropTypes.func.isRequired,
// getMyFollowing: PropTypes.func.isRequired,
// getPublicFollowing: PropTypes.func.isRequired,
getMyFollowing: PropTypes.func.isRequired,
getPublicFollowing: PropTypes.func.isRequired,
getMyDID: PropTypes.func.isRequired,
getCollectibles: PropTypes.func.isRequired,
getMySpacesData: PropTypes.func.isRequired,
Expand Down Expand Up @@ -515,7 +514,7 @@ export default withRouter(connect(mapState,
getVerifiedPublicTwitter,
getVerifiedPrivateEmail,
getActivity,
// getMyFollowing,
getMyFollowing,
handleSignInModal,
handleSwitchedNetworkModal,
handleAccessModal,
Expand All @@ -527,7 +526,7 @@ export default withRouter(connect(mapState,
handleOnboardingModal,
handleFollowingPublicModal,
closeErrorModal,
// getPublicFollowing,
getPublicFollowing,
saveFollowing,
handleContactsModal,
clearReduxState,
Expand Down
4 changes: 2 additions & 2 deletions src/AppRoutes.jsx
Expand Up @@ -107,11 +107,11 @@ const AppRoutes = props => (
render={() => <MyProfile handleSignInUp={props.handleSignInUp} />}
/>

{/* <Route
<Route
exact
path="(^[/][0][xX]\w{40}\b)/following"
render={() => <MyProfile handleSignInUp={props.handleSignInUp} />}
/> */}
/>

<Route
exact
Expand Down
6 changes: 0 additions & 6 deletions src/MainApp.jsx
Expand Up @@ -56,8 +56,6 @@ const {
getVerifiedPublicTwitter,
getVerifiedPrivateEmail,
getActivity,
// getMyFollowing,
// getPublicFollowing,
saveFollowing,
} = actions.profile;

Expand Down Expand Up @@ -363,8 +361,6 @@ App.propTypes = {
getMyProfileValue: PropTypes.func.isRequired,
checkWeb3: PropTypes.func.isRequired,
initialCheckWeb3: PropTypes.func.isRequired,
// getMyFollowing: PropTypes.func.isRequired,
// getPublicFollowing: PropTypes.func.isRequired,
getMyDID: PropTypes.func.isRequired,
getCollectibles: PropTypes.func.isRequired,
getMySpacesData: PropTypes.func.isRequired,
Expand Down Expand Up @@ -515,7 +511,6 @@ export default withRouter(connect(mapState,
getVerifiedPrivateEmail,
getActivity,
initialCheckWeb3,
// getMyFollowing,
requireMetaMaskModal,
handleMobileWalletModal,
handleSignInModal,
Expand All @@ -531,7 +526,6 @@ export default withRouter(connect(mapState,
handleFollowingPublicModal,
closeErrorModal,
closeRequireMetaMaskModal,
// getPublicFollowing,
saveFollowing,
handleContactsModal,
})(App));
9 changes: 1 addition & 8 deletions src/components/FollowingTile.jsx
Expand Up @@ -4,15 +4,10 @@ import { Link } from 'react-router-dom';
import { connect } from 'react-redux';
import ProfileHover from 'profile-hover';

import actions from '../state/actions';
import '../views/Profile/styles/Profile.css';
import FollowButton from '../views/Profile/PublicProfile/FollowButton';
import DefaultProfile from '../assets/DefaultProfile.svg';

const {
saveFollowing,
} = actions.profile;

class FollowingTile extends Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -105,6 +100,4 @@ function mapState(state) {
};
}

export default connect(mapState, {
saveFollowing,
})(FollowingTile);
export default connect(mapState)(FollowingTile);
2 changes: 2 additions & 0 deletions src/components/styles/Modal.css
Expand Up @@ -1171,6 +1171,8 @@
margin-top: 60px; }
.modal__container img {
width: 100px; }
.followingModal {
width: 85vw !important; }
.onClickOutsideCollectibles {
display: none; }
.modal__loading__mollie {
Expand Down
4 changes: 4 additions & 0 deletions src/components/styles/Modal.scss
Expand Up @@ -1478,6 +1478,10 @@
}
}

.followingModal {
width: 85vw !important;
}

.onClickOutsideCollectibles {
display: none;
}
Expand Down
3 changes: 2 additions & 1 deletion src/index.css
Expand Up @@ -182,7 +182,8 @@ button {
background-color: transparent;
border: solid 1px #7a7a7a;
color: #7a7a7a;
box-shadow: none; }
box-shadow: none;
padding: 15px 20px; }
.outlineButton:hover {
border: solid 1px #7a7a7a;
color: #7a7a7a;
Expand Down
1 change: 1 addition & 0 deletions src/index.scss
Expand Up @@ -228,6 +228,7 @@ button {
border: solid 1px #7a7a7a;
color: #7a7a7a;
box-shadow: none;
padding: 15px 20px;

&:hover {
border: solid 1px #7a7a7a;
Expand Down
4 changes: 2 additions & 2 deletions src/state/actions/profile/getMyData.js
Expand Up @@ -12,7 +12,7 @@ import getVerifiedPublicTwitter from './getVerifiedPublicTwitter';
import getMyMemberSince from './getMyMemberSince';
import getMyDID from './getMyDID';
import getMyProfileValue from './getMyProfileValue';
// import getMyFollowing from './getMyFollowing';
import getMyFollowing from './getMyFollowing';
import getCollectibles from './getCollectibles';
import getActivity from './getActivity';
import convert3BoxToSpaces from '../spaces/convert3BoxToSpaces';
Expand Down Expand Up @@ -52,7 +52,7 @@ const getMyData = async () => {
getMyProfileValue('public', 'emoji'); // eslint-disable-line
getMyProfileValue('private', 'birthday'); // eslint-disable-line

// await getMyFollowing(); // eslint-disable-line
await getMyFollowing(); // eslint-disable-line
await getCollectibles(currentAddress); // eslint-disable-line
await convert3BoxToSpaces(); // eslint-disable-line
await getMySpacesData(currentAddress); // eslint-disable-line
Expand Down
28 changes: 14 additions & 14 deletions src/state/actions/profile/getOtherProfile.js
Expand Up @@ -41,28 +41,28 @@ const getOtherProfile = profileAddress => async (dispatch) => {
twitter: null,
};

// let profiles;
// try {
// profiles = await Box.getThread(followingSpaceName, followingThreadName, profileAddress, true);
// } catch (error) {
// console.log(error);
// }
let profiles;
try {
profiles = await Box.getThread(followingSpaceName, followingThreadName, profileAddress, true);
} catch (error) {
console.log(error);
}

// const otherFollowing = profiles ? await getFollowingProfiles(profiles) : [];
const otherFollowing = profiles ? await getFollowingProfiles(profiles) : [];

// otherFollowing.sort((a, b) => {
// if (!a[0].name) return -1;
// if (a[0].name.toLowerCase() < b[0].name.toLowerCase()) return -1;
// if (a[0].name.toLowerCase() > b[0].name.toLowerCase()) return 1;
// return 0;
// });
otherFollowing.sort((a, b) => {
if (!a[0].name) return -1;
if (a[0].name.toLowerCase() < b[0].name.toLowerCase()) return -1;
if (a[0].name.toLowerCase() > b[0].name.toLowerCase()) return 1;
return 0;
});

dispatch({
type: 'OTHER_PROFILE_UPDATE_VERIFIED_FOLLOWING',
otherGithub: publicVerifiedAccounts.github && publicVerifiedAccounts.github.username,
otherTwitter: publicVerifiedAccounts.twitter && publicVerifiedAccounts.twitter.username,
otherCollectiblesGallery: publicProfile.collectiblesFavorites,
// otherFollowing,
otherFollowing,
});

dispatch({
Expand Down
2 changes: 0 additions & 2 deletions src/state/actions/profile/getPublicFollowing.js
Expand Up @@ -15,9 +15,7 @@ const getPublicFollowing = address => async (dispatch) => {
try {
const myAddress = address || store.getState().userState.currentAddress;

// const config = await Box.getConfig(myAddress);
const followingList = await Box.getThread(followingSpaceName, followingThreadName, myAddress, true);

if (!followingList) return null;

const following = await getFollowingProfiles(followingList);
Expand Down
11 changes: 3 additions & 8 deletions src/state/actions/profile/helpers.js
Expand Up @@ -27,11 +27,9 @@ export const deleteDuplicate = async (duplicates, followingThread) => {
}
};


export const getPosts = async (followingThread) => {
try {
const followingList = await followingThread.getPosts();

// remove duplicates from interface
const userInList = {};
const duplicates = [];
Expand All @@ -43,10 +41,9 @@ export const getPosts = async (followingThread) => {
userInList[user.message.identifier[0].value] = true;
return true;
});
if (duplicates.length > 0) deleteDuplicate(duplicates, followingThread);
// if (duplicates.length > 0) deleteDuplicate(duplicates, followingThread);

const updatedFollowing = await getFollowingProfiles(updatedFollowingList);

store.dispatch({
type: 'MY_FOLLOWING_LIST_UPDATE',
following: updatedFollowing,
Expand All @@ -64,11 +61,9 @@ export const getFollowingThreadAndPosts = async (myAddress) => {
isLoadingMyFollowing: true,
});

// const rootstore = await store.getState().myData.box._rootStore.iterator({limit:-1}).collect().map(e => e.payload.value);
const followingSpace = await store.getState().myData.box.openSpace(followingSpaceName);
const opts = {
members: true,
// firstModerator: myAddress,
};
const followingThread = await followingSpace.joinThread(followingThreadName, opts);
store.dispatch({
Expand All @@ -80,8 +75,8 @@ export const getFollowingThreadAndPosts = async (myAddress) => {
isLoadingMyFollowing: false,
});

await getPosts(followingThread);
followingThread.onUpdate(() => getPosts(followingThread));
getPosts(followingThread);
} catch (error) {
console.log('Error getting thread', error);
}
Expand All @@ -106,4 +101,4 @@ export const formatContact = (proofDid, otherProfileAddress) => {
};

return contact;
};
};
3 changes: 1 addition & 2 deletions src/state/actions/profile/saveFollowing.js
Expand Up @@ -21,7 +21,6 @@ const saveFollowing = (otherProfileAddress, fromWarningModal) => async (dispatch
} = store.getState().myData;
const {
currentAddress,
// isLoggedIn
} = store.getState().userState;

const isFollowing = checkFollowing(followingList, otherProfileAddress);
Expand All @@ -48,7 +47,7 @@ const saveFollowing = (otherProfileAddress, fromWarningModal) => async (dispatch
const profile = await Box.getProfile(otherProfileAddress);
const contact = formatContact(profile.proof_did, otherProfileAddress);

const saved = await store.getState().myData.followingThread.post(contact);
await store.getState().myData.followingThread.post(contact);
// `onUpdate` will handle updateing myFollowing
} catch (error) {
console.error(error);
Expand Down
4 changes: 3 additions & 1 deletion src/state/actions/signin/injectWeb3.js
Expand Up @@ -8,7 +8,9 @@ const injectWeb3 = (
shouldSignOut,
) => async (dispatch) => {
const defaultWallet = outsideLoginWallet || window.localStorage.getItem('defaultWallet'); // eslint-disable-line no-undef
if (chooseWallet || !defaultWallet) {
const isDefaultWalletConnect = defaultWallet && defaultWallet.toLowerCase() === 'walletconnect';

if (chooseWallet || !defaultWallet || isDefaultWalletConnect) {
await pickWallet(directLogin, dispatch, shouldSignOut);
} else {
await useDefaultWallet(defaultWallet, directLogin, dispatch);
Expand Down
2 changes: 1 addition & 1 deletion src/state/actions/signin/openBox.js
Expand Up @@ -111,7 +111,7 @@ const openBox = (fromSignIn, fromFollowButton) => async (dispatch) => {
memberSince: memberSinceDate,
});
history.push(`/${currentAddress}/${routes.EDIT}`);
} else if (!memberSince && (privateActivity.length || publicActivity.length)) {
} else if (!memberSince && ((privateActivity && privateActivity.length) || (publicActivity && publicActivity.length))) {
box.public.set('memberSince', 'Alpha');
}

Expand Down
4 changes: 2 additions & 2 deletions src/utils/constants.js
@@ -1,5 +1,5 @@
export const followingSpaceName = 'Following';
// export const followingSpaceName = 'FollowingFeature';
// export const followingSpaceName = 'Following';
export const followingSpaceName = 'MyFollowing';

export const followingThreadName = 'followingList';

Expand Down
9 changes: 3 additions & 6 deletions src/utils/funcs.js
Expand Up @@ -364,12 +364,9 @@ export const getAuthorsLatestPost = (threadArray, usersDID) => {
};

export const getFollowingProfiles = async (following) => {
const profileCalls = [];
following.forEach((profile) => {
profileCalls.push(Box.getProfile(profile.message.identifier[1].value));
});
const profilePromises = Promise.all(profileCalls);
const profiles = await profilePromises;
const fetchProfile = async (ethAddr) => await Box.getProfile(ethAddr);
const fetchAllProfiles = async () => await Promise.all(following.map(user => fetchProfile(user.message.identifier[1].value)));
const profiles = await fetchAllProfiles();

const profilesAndAddress = [];
profiles.forEach((profile, i) => {
Expand Down

0 comments on commit 9bd2b2c

Please sign in to comment.