From 5843c86a3a3108b3fe04cf2048078c3fcac147c6 Mon Sep 17 00:00:00 2001 From: 1aerostorm Date: Mon, 9 Dec 2024 02:21:48 +0300 Subject: [PATCH] Private groups, Mobile app - fixes (WIP, do not merge) --- .../elements/common/AccountName/index.jsx | 2 +- .../elements/groups/GroupMember.jsx | 7 ++-- .../elements/messages/Message/index.jsx | 32 +++++++++++---- src/components/modules/Modals.jsx | 2 +- .../modules/groups/GroupMembers.jsx | 39 ++++++++++++++++--- src/components/modules/groups/GroupName.jsx | 6 +-- src/components/modules/groups/MyGroups.jsx | 4 +- src/components/modules/groups/MyGroups.scss | 3 ++ src/locales/en.json | 6 ++- src/locales/ru-RU.json | 4 +- src/redux/FetchDataSaga.js | 16 ++++---- src/utils/ServerApiClient.js | 2 +- 12 files changed, 87 insertions(+), 36 deletions(-) diff --git a/src/components/elements/common/AccountName/index.jsx b/src/components/elements/common/AccountName/index.jsx index fa9e578ec..6e0c1936e 100644 --- a/src/components/elements/common/AccountName/index.jsx +++ b/src/components/elements/common/AccountName/index.jsx @@ -10,7 +10,7 @@ class AccountName extends React.Component { super(props) this.state = { defaultOptions: [], - isLoading: true, + isLoading: false, } this.ref = React.createRef() } diff --git a/src/components/elements/groups/GroupMember.jsx b/src/components/elements/groups/GroupMember.jsx index 30a7855d6..c4e89e9a7 100644 --- a/src/components/elements/groups/GroupMember.jsx +++ b/src/components/elements/groups/GroupMember.jsx @@ -1,4 +1,5 @@ import React from 'react' +import { Link } from 'react-router-dom' import tt from 'counterpart' import cn from 'classnames' @@ -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 @@ -101,12 +102,12 @@ class GroupMember extends React.Component { return - + {account} - + {!isSmall && !creatingNew && } diff --git a/src/components/elements/messages/Message/index.jsx b/src/components/elements/messages/Message/index.jsx index 37c1d8a7e..a6031e9af 100644 --- a/src/components/elements/messages/Message/index.jsx +++ b/src/components/elements/messages/Message/index.jsx @@ -33,6 +33,20 @@ 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) + window.open(href, '_blank') + } + } + render() { let username @@ -61,7 +75,7 @@ class Message extends React.Component { const previewWidth = message.previewWidth ? message.previewWidth + 'px' : 'auto'; const previewHeight = message.previewHeight ? message.previewHeight + 'px' : 'auto'; - content = ( + content = ( {src} ); } else { @@ -77,7 +91,7 @@ class Message extends React.Component { if (!href.startsWith('http://') && !href.startsWith('https://')) { href = 'http://' + href; } - spans.push({word}); + spans.push({word}); spans.push(' '); } else if (word.length <= 2 && /(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/.test(word)) { spans.push({word}); @@ -130,12 +144,14 @@ class Message extends React.Component { if (startsSequence) { author =
{ - e.preventDefault() - e.stopPropagation() - this.dropdown.current.click() - }}> - {from} + })}> + { + e.preventDefault() + e.stopPropagation() + this.dropdown.current.click() + }}> + {from} +
avatar = { diff --git a/src/components/modules/groups/GroupMembers.jsx b/src/components/modules/groups/GroupMembers.jsx index 3bbde6f79..18e450340 100644 --- a/src/components/modules/groups/GroupMembers.jsx +++ b/src/components/modules/groups/GroupMembers.jsx @@ -1,5 +1,6 @@ import React from 'react' import { connect } from 'react-redux' +import { Link } from 'react-router-dom' import { Field, ErrorMessage, } from 'formik' import tt from 'counterpart' import { validateAccountName } from 'golos-lib-js/lib/utils' @@ -11,8 +12,8 @@ import AccountName from 'app/components/elements/common/AccountName' import Input from 'app/components/elements/common/Input'; import GroupMember from 'app/components/elements/groups/GroupMember' import LoadingIndicator from 'app/components/elements/LoadingIndicator' -import MarkNotificationRead from 'app/components/elements/MarkNotificationRead' import { getRoleInGroup, getGroupMeta, getGroupTitle } from 'app/utils/groups' +import isScreenSmall from 'app/utils/isScreenSmall' export async function validateMembersStep(values, errors) { // nothing yet... @@ -149,7 +150,7 @@ class GroupMembers extends React.Component { } render() { - const { currentGroup, group, username } = this.props + const { currentGroup, group, username, closeMe } = this.props const loading = this.isLoading() let members = group && group.get('members') if (members) members = members.get('data') @@ -162,6 +163,12 @@ class GroupMembers extends React.Component { amModer = true } + const isSmall = isScreenSmall() + + const linkClick = () => { + if (closeMe) closeMe() + } + let mems if (loading) { mems =
@@ -178,6 +185,7 @@ class GroupMembers extends React.Component { mems.push() } @@ -197,7 +205,7 @@ class GroupMembers extends React.Component { {amModer ?
{ @@ -222,7 +230,7 @@ class GroupMembers extends React.Component {
} else { - const { name, json_metadata, pendings, banneds, } = currentGroup + const { name, owner, json_metadata, pendings, banneds, } = currentGroup const meta = getGroupMeta(json_metadata) let title = getGroupTitle(meta, name) @@ -231,12 +239,31 @@ class GroupMembers extends React.Component { const { showPendings, showBanneds } = this.state + let ownerRight, ownerRow + let ownerBlock = + {tt('group_settings_jsx.owner') + ' - '} + {amOwner ? {tt('g.you')} : + {('@' + owner)}} + + if (isSmall) { + ownerRow =
+
+ {ownerBlock} +
+
+ } else { + ownerRight =
+ {ownerBlock} +
+ } + header =

{title}

+ {ownerRow} {amModer ?
+ {ownerRight}
:
{this._renderMemberTypeSwitch()} + {ownerRight}
} - {(username && showPendings) ? : null}
} diff --git a/src/components/modules/groups/GroupName.jsx b/src/components/modules/groups/GroupName.jsx index 46c467025..856fc5679 100644 --- a/src/components/modules/groups/GroupName.jsx +++ b/src/components/modules/groups/GroupName.jsx @@ -19,10 +19,10 @@ export async function validateNameStep(values, errors) { for (let i = 0; i < 3; ++i) { try { console.time('group_exists') - group = await api.getGroupsAsync({ + group = (await api.getGroupsAsync({ start_group: values.name, limit: 1 - }) + })).groups console.timeEnd('group_exists') break } catch (err) { @@ -30,7 +30,7 @@ export async function validateNameStep(values, errors) { errors.name = 'Blockchain unavailable :(' } } - if (group && group[0] && group[0].name === values.name) { + if (group[0] && group[0].name === values.name) { errors.name = tt('create_group_jsx.group_already_exists') } } diff --git a/src/components/modules/groups/MyGroups.jsx b/src/components/modules/groups/MyGroups.jsx index 9de07e978..d609c1406 100644 --- a/src/components/modules/groups/MyGroups.jsx +++ b/src/components/modules/groups/MyGroups.jsx @@ -183,7 +183,7 @@ class MyGroups extends React.Component { {(isSmall ? '' : tt('group_members_jsx.check_pending')) + ' (' + pendings + ')'} : null} -
} diff --git a/src/components/modules/groups/MyGroups.scss b/src/components/modules/groups/MyGroups.scss index d0cfc5749..546c1d756 100644 --- a/src/components/modules/groups/MyGroups.scss +++ b/src/components/modules/groups/MyGroups.scss @@ -44,4 +44,7 @@ display: none; } } + .button.force-white { + color: #fefefe !important; + } } diff --git a/src/locales/en.json b/src/locales/en.json index 3f0dbb4e7..95d4a9fd8 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -181,7 +181,8 @@ "members_list": "Members:", "image_wrong": "Cannot load this image.", "image_timeout": "Cannot load this image, it is loading too long...", - "add_member": "+ Add Member..." + "add_member": "+ Add Member...", + "add_member2": "+ Add..." }, "my_groups_jsx": { "title": "My Groups", @@ -389,6 +390,7 @@ "submit": "Submit", "unblock": "Unblock", "username_does_not_exist": "Username does not exist", - "wallet": "Wallet" + "wallet": "Wallet", + "you": "you" } } diff --git a/src/locales/ru-RU.json b/src/locales/ru-RU.json index 910190bc4..b18dc9020 100644 --- a/src/locales/ru-RU.json +++ b/src/locales/ru-RU.json @@ -189,6 +189,7 @@ "image_wrong": "Не удается загрузить картинку.", "image_timeout": "Не удается загрузить картинку, она загружается слишком долго...", "add_member": "+ Добавить участника...", + "add_member2": "+ Добавить...", "cannot_set_members": "Группа создана успешно. Но, к сожалению, не получилось задать участников из-за ошибки.", "cannot_set_members2": "Вы можете попытаться сделать это заново в настройках группы." }, @@ -407,6 +408,7 @@ "unblock": "Разблокировать", "username_does_not_exist": "Такого имени не существует", "wallet": "Кошелек", - "wait": "Ждите..." + "wait": "Ждите...", + "you": "вы" } } \ No newline at end of file diff --git a/src/redux/FetchDataSaga.js b/src/redux/FetchDataSaga.js index e27de9470..7700ca96e 100644 --- a/src/redux/FetchDataSaga.js +++ b/src/redux/FetchDataSaga.js @@ -129,8 +129,8 @@ export function* fetchState(location_change_action) { } }) if (hasErr) return - if (the_group[0] && the_group[0].name === path) { - the_group = the_group[0] + if (the_group && the_group.groups && the_group.groups[0] && the_group.groups[0].name === path) { + the_group = the_group.groups[0] } else { the_group = null } @@ -226,7 +226,7 @@ export function* watchFetchMyGroups() { export function* fetchMyGroups({ payload: { account } }) { try { - const groupsOwn = yield call([api, api.getGroupsAsync], { + const groupsOwn = (yield call([api, api.getGroupsAsync], { member: account, member_types: [], start_group: '', @@ -234,8 +234,8 @@ export function* fetchMyGroups({ payload: { account } }) { with_members: { accounts: [account] } - }) - let groups = yield call([api, api.getGroupsAsync], { + })).groups + let groups = (yield call([api, api.getGroupsAsync], { member: account, member_types: ['pending', 'member', 'moder'], start_group: '', @@ -243,7 +243,7 @@ export function* fetchMyGroups({ payload: { account } }) { with_members: { accounts: [account] } - }) + })).groups groups = [...groupsOwn, ...groups] groups.sort((a, b) => { return b.pendings - a.pendings @@ -269,7 +269,7 @@ export function* fetchTopGroups({ payload: { account } }) { groupsWithoutMe.pop() } - const groups = yield call([api, api.getGroupsAsync], { + const { groups } = yield call([api, api.getGroupsAsync], { sort: 'by_popularity', start_group, limit: 100, @@ -310,7 +310,7 @@ export function* fetchGroupMembers({ payload: { group, creatingNew, memberTypes, yield put(g.actions.receiveGroupMembers({ group, loading: true })) - const members = yield call([api, api.getGroupMembersAsync], { + const { members } = yield call([api, api.getGroupMembersAsync], { group, member_types: memberTypes, sort_conditions: sortConditions, diff --git a/src/utils/ServerApiClient.js b/src/utils/ServerApiClient.js index 8d9fff818..7e8d04c8b 100644 --- a/src/utils/ServerApiClient.js +++ b/src/utils/ServerApiClient.js @@ -3,7 +3,7 @@ import { fetchEx } from 'golos-lib-js/lib/utils' export function getHost() { const { location, } = window; if (process.env.NODE_ENV === 'development') { - return location.protocol + '//'+ location.hostname + ':8080'; + return location.protocol + '//'+ location.hostname + ':8088'; } return location.origin; }