Skip to content

Commit

Permalink
Merge pull request #26 from golos-blockchain/dev
Browse files Browse the repository at this point in the history
Private groups, Mobile app - fixes
  • Loading branch information
Lex-Ai authored Dec 14, 2024
2 parents 57c8c40 + abb9aba commit a4670bf
Show file tree
Hide file tree
Showing 25 changed files with 413 additions and 84 deletions.
20 changes: 18 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import AppSettings, { openAppSettings } from 'app/components/pages/app/AppSettin
import Themifier from 'app/Themifier'
import Translator from 'app/Translator'
import initConfig from 'app/utils/initConfig'
import RenderError from 'app/utils/RenderError'
import { getShortcutIntent, onShortcutIntent } from 'app/utils/app/ShortcutUtils'

import 'app/App.scss'
Expand Down Expand Up @@ -68,6 +69,20 @@ class App extends React.Component {
})
}

componentDidCatch(err, info) {
console.error('Render error:', err, info)
const errStr = (err && err.toString()) ? err.toString() : JSON.stringify(err)
const infoStr = (info && info.componentStack) || JSON.stringify(info)
this.setState({
fatalErr: {
errStr,
infoStr
}
})
//alert(';( Ошибка рендеринга\n\n' + errStr + '\n' + infoStr)
//throw err
}

showAppReminder = () => {
if (process.env.MOBILE_APP || process.env.DESKTOP_APP) {
return
Expand All @@ -87,10 +102,11 @@ class App extends React.Component {
</div>
}
const reminder = this.showAppReminder() ? <AppReminder /> : null
const { fatalErr } = this.state
return (
<Provider store={store}>
<Translator>
<ConnectedRouter history={history}>
{fatalErr ? <RenderError error={fatalErr} /> : <ConnectedRouter history={history}>
<Switch>
<Route path='/__app_settings'>
<Themifier>
Expand All @@ -110,7 +126,7 @@ class App extends React.Component {
</Themifier>}
</Route>
</Switch>
</ConnectedRouter>
</ConnectedRouter>}
</Translator>
</Provider>
)
Expand Down
19 changes: 16 additions & 3 deletions src/app/default_cfg.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
module.exports = {
"app_version": "1.0.0",
"app_version": "1.0.1",
"nodes": [
{
"address": "wss://apibeta.golos.today/ws"
},
{
"address": "wss://api.golos.id/ws"
},
{
"address": "wss://api.aleksw.space/ws"
},
{
"address": "wss://api-golos.blckchnd.com/ws"
}
],
"images": {
Expand All @@ -16,12 +25,16 @@ module.exports = {
"custom_client": "blogs"
},
"notify_service": {
"host": "https://devnotify.golos.app"
"host": "https://devnotify.golos.app",
"host_ws": "wss://devnotify.golos.app/ws"
},
"blogs_service": {
"host": "https://beta.golos.today"
},
"wallet_service": {
"host": "https://devwallet.golos.today"
},
"app_updater": {
"host": "https://files.golos.app"
"host": "https://devfiles.golos.app"
}
}
16 changes: 12 additions & 4 deletions src/components/elements/MarkNotificationRead.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class MarkNotificationRead extends React.Component {
account: PropTypes.string,
update: PropTypes.func,
interval: PropTypes.number,
delay: PropTypes.number,
};

shouldComponentUpdate(nextProps) {
Expand All @@ -37,12 +38,19 @@ class MarkNotificationRead extends React.Component {
}

componentDidMount() {
const { account, fields, update, interval } = this.props;
const { account, fields, update, interval, delay } = this.props;
this.fields_array = fields.replace(/\s/g,'').split(',');
if (interval)
const firstMark = () => {
markNotificationRead(account, this.fields_array).then(nc => update(nc))
}
if (delay) {
setTimeout(firstMark, delay)
}
if (interval) {
this._activateInterval(interval);
else
markNotificationRead(account, this.fields_array).then(nc => update(nc));
} else if (!delay) {
firstMark()
}
}

componentDidUpdate() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/elements/VerticalMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default class VerticalMenu extends React.Component {
const LinkType = i.extLink ? ExtLink : Link
const service = i.extLink || undefined
return <li data-link={i.link} data-value={i.value} key={i.key ? i.key : i.value} onClick={i.link ? this.closeMenu : null}>
{i.link ? <LinkType to={i.link} target={target} onClick={i.onClick} service={service}>
{i.link ? <LinkType to={i.link} target={target} onClick={i.onClick} onTouchStart={i.onTouchStart} onTouchEnd={i.onTouchEnd} service={service}>
{i.icon && <Icon name={i.icon} size={iconSize} />}{i.label ? i.label : i.value}
{i.data && <span>{i.data}</span>}
&nbsp; {i.addon}
Expand Down
2 changes: 1 addition & 1 deletion src/components/elements/common/AccountName/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AccountName extends React.Component {
super(props)
this.state = {
defaultOptions: [],
isLoading: true,
isLoading: false,
}
this.ref = React.createRef()
}
Expand Down
7 changes: 4 additions & 3 deletions src/components/elements/groups/GroupMember.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import { Link } from 'react-router-dom'
import tt from 'counterpart'
import cn from 'classnames'

Expand Down Expand Up @@ -53,7 +54,7 @@ class GroupMember extends React.Component {
}

render() {
const { member, username, currentGroup } = this.props
const { member, username, currentGroup, linkClick } = this.props
const { account, member_type, joined } = member
const { creatingNew, } = currentGroup

Expand Down Expand Up @@ -101,12 +102,12 @@ class GroupMember extends React.Component {

return <tr key={account}>
<td style={{ paddingBottom: '0px' }}>
<a href={'/@' + account} target='_blank' rel='noopener noreferrer'>
<Link to={'/@' + account} onClick={linkClick || undefined}>
<Userpic account={account} title={account} width={40} height={40} />
<span className='member-name'>
{account}
</span>
</a>
</Link>
</td>
<td>
{!isSmall && !creatingNew && <TimeAgoWrapper date={joined} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
}

.conversation-info {
width: 100%;
width: calc(100% - 60px);
}

.conversation-snippet {
Expand Down
14 changes: 14 additions & 0 deletions src/components/elements/messages/Message/Message.css
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,17 @@
.msgs-message.mine .bubble-container.selected .quote-from {
color: white;
}

.msgs-adds {
display: flex;
}

@media screen and (max-width: 39.9375em) {
.msgs-adds {
display: block;

.msgs-donating {
margin-left: 3px;
}
}
}
49 changes: 38 additions & 11 deletions src/components/elements/messages/Message/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import {connect} from 'react-redux'
import { Fade } from 'react-foundation-components/lib/global/fade'
import { LinkWithDropdown } from 'react-foundation-components/lib/global/dropdown'
import { withRouter } from 'react-router'
import { Link } from 'react-router-dom'
import tt from 'counterpart';
import cn from 'classnames'
Expand Down Expand Up @@ -33,6 +34,30 @@ class Message extends React.Component {
event.stopPropagation();
};

linkClicked = (event) => {
this.doNotSelectMessage(event)
if (process.env.MOBILE_APP) {
event.preventDefault()
let node, href
do {
node = node ? node.parentNode : event.target
if (!node) break
href = node.href
} while (!href)
try {
let url = new URL(href)
if (url.host === location.host) {
const { history } = this.props
history.push(url.pathname)
return
}
} catch (err) {
console.error(err)
}
window.open(href, '_system')
}
}

render() {
let username

Expand Down Expand Up @@ -61,7 +86,7 @@ class Message extends React.Component {
const previewWidth = message.previewWidth ? message.previewWidth + 'px' : 'auto';
const previewHeight = message.previewHeight ? message.previewHeight + 'px' : 'auto';

content = (<a href={src} target='_blank' rel='noopener noreferrer' tabIndex='-1' onClick={this.doNotSelectMessage}>
content = (<a href={src} target='_blank' rel='noopener noreferrer' tabIndex='-1' onClick={this.linkClicked}>
<img src={srcPreview} alt={src} style={{width: previewWidth, height: previewHeight, objectFit: 'cover'}} />
</a>);
} else {
Expand All @@ -77,7 +102,7 @@ class Message extends React.Component {
if (!href.startsWith('http://') && !href.startsWith('https://')) {
href = 'http://' + href;
}
spans.push(<a href={href} target='_blank' rel='noopener noreferrer' key={key} tabIndex='-1' onClick={this.doNotSelectMessage}>{word}</a>);
spans.push(<a href={href} target='_blank' rel='noopener noreferrer' key={key} tabIndex='-1' onClick={this.linkClicked}>{word}</a>);
spans.push(' ');
} else if (word.length <= 2 && /(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/.test(word)) {
spans.push(<span key={key++} style={{fontSize: '20px'}}>{word}</span>);
Expand Down Expand Up @@ -130,12 +155,14 @@ class Message extends React.Component {
if (startsSequence) {
author = <div className={cn('author', {
banned: isBanned
})} onClick={(e) => {
e.preventDefault()
e.stopPropagation()
this.dropdown.current.click()
}}>
{from}
})}>
<span onClick={(e) => {
e.preventDefault()
e.stopPropagation()
this.dropdown.current.click()
}}>
{from}
</span>
</div>

avatar = <LinkWithDropdown
Expand Down Expand Up @@ -179,14 +206,14 @@ class Message extends React.Component {
{ quoteHeader }
{ content }
</div>
{!isMine ? adds : null}
{!isMine ? <div className='msgs-adds'>{adds}</div> : null}
</div>
</div>
);
}
}

export default connect(
export default withRouter(connect(
(state, ownProps) => {
const accounts = state.global.get('accounts')

Expand All @@ -199,4 +226,4 @@ export default connect(
},
dispatch => ({
}),
)(Message)
)(Message))
9 changes: 6 additions & 3 deletions src/components/modules/MessagesTopCenter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,13 @@ class MessagesTopCenter extends React.Component {
this.setState({ refreshing: true })
e.preventDefault()
e.stopPropagation()
this.props.fetchState(this.props.to)
this.props.loginUser()
setTimeout(() => {
this.setState({ refreshing: false })
}, 500)
this.props.fetchState(this.props.to)
setTimeout(() => {
this.setState({ refreshing: false })
}, 500)
}, 1000)
}

render() {
Expand Down
1 change: 1 addition & 0 deletions src/components/modules/MessagesTopCenter.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
@media screen and (max-width: 39.9375em) {
.GroupDropdown {
left: 10px !important;
position: fixed;
}
}

Expand Down
14 changes: 10 additions & 4 deletions src/components/modules/Modals.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import LoginForm from 'app/components/modules/LoginForm';
import AppDownload from 'app/components/modules/app/AppDownload'
import user from 'app/redux/UserReducer'
//import tr from 'app/redux/Transaction';
import isScreenSmall from 'app/utils/isScreenSmall'

let keyIndex = 0;

Expand Down Expand Up @@ -76,10 +77,15 @@ class Modals extends React.Component {
return n;
}) : [];

const modalStyle = {
borderRadius: '8px',
boxShadow: '0 0 19px 3px rgba(0,0,0, 0.2)',
overflow: 'hidden',
let modalStyle = {
overflowX: 'hidden',
}
if (!isScreenSmall()) {
modalStyle = {
borderRadius: '8px',
boxShadow: '0 0 19px 3px rgba(0,0,0, 0.2)',
...modalStyle,
}
}

const doHideLogin = (e) => {
Expand Down
Loading

0 comments on commit a4670bf

Please sign in to comment.