Skip to content

Commit e728d49

Browse files
committed
more grooviness!
1 parent 2747ae9 commit e728d49

File tree

4 files changed

+85
-53
lines changed

4 files changed

+85
-53
lines changed

src/actions/profilesActions.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ let unauthorizedBox: typeof Box;
2424
let didResolver: any;
2525

2626
export async function initialize3Box(): Promise<void> {
27+
console.log("create");
2728
unauthorizedBox = await Box.create();
29+
console.log("getIPFS");
2830
const ipfs = await Box.getIPFS();
2931
const threeboxDidResolver = getResolver(ipfs);
3032
didResolver = new Resolver(threeboxDidResolver);
@@ -62,7 +64,7 @@ async function get3Box(accountAddress: Address, dispatch: any, state: any, withS
6264
}
6365

6466
await assert3Box();
65-
67+
console.log("auth");
6668
await unauthorizedBox.auth([], { address: accountAddress, provider: web3Provider });
6769
await unauthorizedBox.syncDone;
6870
/**

src/components/Account/Account.scss

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,11 @@ a.detailView {
4040

4141
.avatar {
4242
z-index: 1;
43-
position: absolute;
44-
top: 50%;
45-
left: 50%;
46-
transform: translate(-50%, -50%);
4743
background-color: rgba(255, 255, 255, 0);
4844
transition: all 0.25s ease;
4945

5046
img {
5147
transition: all 0.25s ease;
52-
position: absolute;
53-
top: 50%;
54-
left: 50%;
55-
transform: translate(-50%, -50%);
5648
}
5749
}
5850

@@ -138,16 +130,6 @@ a.accountName {
138130
.targetAccount:hover {
139131
z-index: 10000000;
140132

141-
.avatar {
142-
width: 80px;
143-
height: 80px;
144-
145-
img {
146-
width: 50px;
147-
height: 50px;
148-
}
149-
}
150-
151133
.accountInfo {
152134
opacity: 1;
153135
top: 0px;

src/components/Dao/DaoLandingPage.scss

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,33 +88,51 @@
8888
border: $disabled-button-border;
8989
cursor: not-allowed;
9090
}
91+
92+
img.loading {
93+
position: relative;
94+
top: 5px;
95+
width: 18px;
96+
margin-left: 6px;
97+
}
9198
}
9299
}
93100

94101
.threeboxposts {
95102
display: flex;
96103
flex-direction: column;
97104
.threeboxpost {
98-
margin-bottom: 20px;
105+
margin-bottom: 26px;
106+
display: flex;
99107

100-
.author {
101-
display: inline-block;
102-
margin-right: 12px;
108+
.column1 {
109+
margin-right: 10px;
103110
}
104111

105-
.createdOn {
106-
display: inline-block;
107-
font-size: 12px;
108-
}
109-
110-
.message {
111-
padding: 20px;
112+
.column2 {
113+
display: flex;
114+
flex-direction: column;
115+
116+
.info {
117+
.author {
118+
display: inline-block;
119+
margin-right: 8px;
120+
}
121+
.createdOn {
122+
font-size: 12px;
123+
display: inline-block;
124+
}
125+
}
126+
127+
.message {
128+
padding-bottom: 0; // stub
129+
}
112130
}
113131
}
114132
}
115133

116134
.threeboxCommentInput {
117-
margin-bottom: 20px;
135+
margin-bottom: 26px;
118136

119137
.commentsInput {
120138
width: 100%;
@@ -131,7 +149,9 @@
131149
white-space: nowrap;
132150

133151
&:hover {
134-
opacity: 0.8;
152+
background-color: $gray-1;
153+
color: $white;
154+
border-color: transparent;
135155
}
136156
}
137157
}

src/components/Dao/DaoLandingPage.tsx

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ import { connect } from "react-redux";
1414
import { I3BoxThread, I3BoxThreadPost, IProfilesState } from "reducers/profilesReducer";
1515
import { IRootState } from "reducers";
1616
import { enableWalletProvider, getAccountIsEnabled } from "arc";
17-
import { showNotification } from "reducers/notifications";
17+
import { NotificationStatus, showNotification } from "reducers/notifications";
1818
import AccountPopup from "components/Account/AccountPopup";
1919
import AccountProfileName from "components/Account/AccountProfileName";
20+
import { SortOrder, SortService } from "lib/sortService";
2021

2122
type IExternalProps = {
2223
daoState: IDAOState;
@@ -35,6 +36,7 @@ interface IExternalStateProps {
3536
interface IStateProps {
3637
threeboxPosts?: Array<I3BoxThreadPost>;
3738
joinedThread?: I3BoxThread;
39+
joiningThread?: boolean;
3840
}
3941

4042
const mapDispatchToProps = {
@@ -62,6 +64,7 @@ class DaoLandingPage extends React.Component<IProps, IStateProps> {
6264
this.state = {
6365
threeboxPosts: null,
6466
joinedThread: null,
67+
joiningThread: false,
6568
};
6669
}
6770

@@ -70,6 +73,10 @@ class DaoLandingPage extends React.Component<IProps, IStateProps> {
7073
return joinThread(this.props.daoState.id, this.props.currentAccountAddress, this.props.profiles);
7174
}
7275

76+
private getPosts = async () => {
77+
return (await getPosts(this.props.daoState.id)).sort((a, b) =>
78+
{ return SortService.evaluateDateTime(a.createDate, b.createDate, SortOrder.DESC); });
79+
}
7380
public async componentDidMount(): Promise<void> {
7481
Analytics.track("Page View", {
7582
"Page Name": Page.DAOLanding,
@@ -83,14 +90,14 @@ class DaoLandingPage extends React.Component<IProps, IStateProps> {
8390
subcribeToThread(thread, this.handleNewPosts);
8491
state.joinedThread = thread;
8592
}
86-
const posts = await getPosts(this.props.daoState.id);
93+
const posts = await this.getPosts();
8794
state.threeboxPosts = posts;
8895

8996
this.setState(state);
9097
}
9198

9299
private handleNewPosts = async () => {
93-
const posts = await getPosts(this.props.daoState.id);
100+
const posts = await this.getPosts();
94101
this.setState({ threeboxPosts: posts });
95102
}
96103

@@ -108,19 +115,34 @@ class DaoLandingPage extends React.Component<IProps, IStateProps> {
108115
}
109116

110117
private startDiscussion = async () => {
111-
if (!this.state.joinedThread) {
112-
if (!await enableWalletProvider({ showNotification: this.props.showNotification })) {
113-
return;
114-
} else {
115-
await waitUntilTrue(() => !!this.props.currentAccountAddress && getAccountIsEnabled(), 60000);
116-
await this.props.threeboxLogin(this.props.currentAccountAddress);
117-
await waitUntilTrue(() => !!this.props.profiles.threeBoxSpace, 60000);
118-
const thread = await this.get3BoxThread();
119-
if (thread) {
120-
subcribeToThread(thread, this.handleNewPosts);
121-
this.setState({ joinedThread: thread });
118+
let joining = false;
119+
try {
120+
if (!this.state.joinedThread) {
121+
joining = true;
122+
this.setState({ joiningThread: true });
123+
await waitUntilTrue(() => this.state.joiningThread, 10000);
124+
125+
if (!await enableWalletProvider({ showNotification: this.props.showNotification })) {
126+
return;
127+
} else {
128+
await waitUntilTrue(() => !!this.props.currentAccountAddress && getAccountIsEnabled(), 15000);
129+
await this.props.threeboxLogin(this.props.currentAccountAddress);
130+
await waitUntilTrue(() => !!this.props.profiles.threeBoxSpace, 30000);
131+
const thread = await this.get3BoxThread();
132+
if (thread) {
133+
subcribeToThread(thread, this.handleNewPosts);
134+
this.setState({ joinedThread: thread });
135+
} else {
136+
showNotification(NotificationStatus.Failure, "Unable to join the conversation");
137+
}
122138
}
123139
}
140+
} catch (ex) {
141+
showNotification(NotificationStatus.Failure, `Unable to join the conversation: ${ex?.message ?? "unknown error"}`);
142+
} finally {
143+
if (joining) {
144+
this.setState({ joiningThread: false });
145+
}
124146
}
125147
}
126148

@@ -173,8 +195,10 @@ class DaoLandingPage extends React.Component<IProps, IStateProps> {
173195
<div className={css.headerText}>Discuss {daoState.name}</div>
174196
<div className={css.discussionWarning}>IMPORTANT! We are moving from Disqus to 3Box for commenting! Before long, all the Disqus comments will disappear. So for a short time we are making both systems available here so that you may copy important comments from Disqus into 3Box, before the Disqus comments all disappear.</div>
175197
<div className={css.startDiscussionButton}>
176-
{((this.state.threeboxPosts !== null) && (!this.state.threeboxPosts.length || !this.state.joinedThread)) ?
177-
<a onClick={this.startDiscussion}>{this.state.threeboxPosts.length ? "Join the Conversation" : "Start a Conversation"}</a>
198+
{ !this.state.joinedThread ?
199+
<a onClick={this.startDiscussion}>{this.state.threeboxPosts?.length ? "Join the Conversation" : "Start a Conversation"}
200+
{this.state.joiningThread ? <img className={css.loading} src="/assets/images/Icon/Loading-white.svg" /> : ""}
201+
</a>
178202
: ""
179203
}
180204
</div>
@@ -188,12 +212,16 @@ class DaoLandingPage extends React.Component<IProps, IStateProps> {
188212
<div className={css.threeboxposts}>
189213
{this.state.threeboxPosts.map((post, index) => {
190214
return (<div key={index} className={css.threeboxpost}>
191-
<div className={css.author}>
192-
<AccountPopup accountAddress={post.author} daoState={daoState} />
193-
<AccountProfileName accountAddress={post.author} accountProfile={this.props.profiles[post.author]} daoAvatarAddress={daoState.address} />
215+
<div className={css.column1}>
216+
<AccountPopup accountAddress={post.author} daoState={daoState} width={38} />
217+
</div>
218+
<div className={css.column2}>
219+
<div className={css.info}>
220+
<div className={css.author}><AccountProfileName accountAddress={post.author} accountProfile={this.props.profiles[post.author]} daoAvatarAddress={daoState.address} /></div>
221+
<div className={css.createdOn}>{formatFriendlyDateForLocalTimezone(post.createDate)}</div>
222+
</div>
223+
<div className={css.message}>{post.message}</div>
194224
</div>
195-
<div className={css.createdOn}>({formatFriendlyDateForLocalTimezone(post.createDate)})</div>
196-
<div className={css.message}>{post.message}</div>
197225
</div>);
198226
})
199227
}

0 commit comments

Comments
 (0)