This commit is contained in:
srgooglo 2020-02-13 10:31:45 +01:00
parent 5881c52339
commit c392515b21
7 changed files with 84 additions and 25 deletions

View File

@ -26,6 +26,7 @@ module.exports = {
openwheater_apiKey:'2acf34be0b8f033b89ba4de1e674d42a',
},
Endpoints: {
get_user_posts: "https://api.ragestudio.net/RS-YIBTP/yid/posts?access_token=",
find_user: "https://api.ragestudio.net/RS-YIBTP/yid/find_user?access_token=",
search_endpoint: "https://api.ragestudio.net/RS-YIBTP/yid/search?access_token=",
get_sessions: "https://api.ragestudio.net/RS-YIBTP/yid/session_id?access_token=",

View File

@ -41,6 +41,13 @@ export const UIFxList = {
notifySuccess: (ycore_worker.FXapiProvider + 'notifySuccess.wav')
};
export function booleanFix(e){
if(e == 1){
return true
}
return false
}
export const crouter = {
native: (e) =>{
umiRouter.push({
@ -116,6 +123,32 @@ export function SeachKeywords(key, callback){
});
}
export function GetUserPosts(id, callback) {
let formdata = new FormData();
formdata.append("server_key", yConfig.server_key);
formdata.append("type", "get_user_posts");
formdata.append("id", id)
const urlOBJ = `${endpoints.get_user_posts}${GetUserToken.decrypted().UserToken}`
const settings = {
"url": urlOBJ,
"method": "POST",
"timeout": 10000,
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": formdata
};
jquery.ajax(settings)
.done(function (response) {
return callback(null, response);
})
.fail(function (response) {
const exception = 'Request Failed';
return callback(exception, response);
});
}
export function GetFeedPosts(callback) {
let formdata = new FormData();
@ -135,8 +168,6 @@ export function GetFeedPosts(callback) {
return callback( null, result)
})
.catch(error => console.log('error', error));
}
export const get_app_session = {

View File

@ -9,7 +9,6 @@ import styles from './Header.less'
import { config } from 'utils'
import * as ycore from 'ycore'
import router from 'umi/router'
import moment from 'moment'
@withI18n()
@ -112,7 +111,7 @@ class Header extends PureComponent {
<Layout.Header id='layoutHeader' className={classnames(styles.header, {[styles.fixed]: fixed}, {[styles.collapsed]: !collapsed} )} >
<div className={classnames(styles.containersWrappers, {[styles.collapsed]: !collapsed})} >
<div className={styles.leftContainer}>
<Tooltip title={'Main'}><Icon type="home" className={styles.iconButton} style={{ fontSize: '15px' }} /></Tooltip>
<Tooltip title={'Main'}><Icon type="home" className={styles.iconButton} onClick={() => ycore.crouter.native('main')} style={{ fontSize: '15px' }} /></Tooltip>
<Tooltip title={'Search'}><Icon type="search" className={styles.iconButton} style={{ fontSize: '15px' }} /></Tooltip>
</div>
<div className={styles.rightContainer}>

View File

@ -169,7 +169,7 @@ class L_Sider extends PureComponent {
<div className={styles.siderhead}>
<antd.Avatar size={collapsed? "small" : "large"} shape={collapsed? "circle" : "square"} src={userData.avatar} className={collapsed? styles.avatar : styles.avatarFull} />
</div>
{collapsed? null : <div className={styles.userInfo}><h2>@{userData.username}</h2></div> }
{collapsed? null : <div className={styles.userInfo}><a href={`/@${userData.username}`}><h2>@{userData.username}</h2></a></div> }
</div>
</ScrollBar>
</div>

View File

@ -69,7 +69,7 @@ class PostCard extends React.PureComponent{
<antd.Card actions={actions} >
<Meta
avatar={<div className={styles.postAvatar}><antd.Avatar shape="square" size={50} src={avatar} /></div>}
title={<div><h4 className={styles.titleUser}>@{user} {this.isVerifiedAccount(publisher)? <antd.Icon style={{ color: 'blue' }} component={CustomIcons.VerifiedBadge} /> : null}</h4></div>}
title={<div><a href={`/@${user}`}><h4 className={styles.titleUser}>@{user} {this.isVerifiedAccount(publisher)? <antd.Icon style={{ color: 'blue' }} component={CustomIcons.VerifiedBadge} /> : null}</h4></a></div>}
description={<span className={styles.textAgo}>{ago}</span>}
bordered="false"
/>

View File

@ -3,7 +3,7 @@ import styles from './styles.less'
import * as ycore from 'ycore'
import * as antd from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { string } from 'prop-types';
import {CustomIcons, PostCard} from 'components'
const userData = ycore.SDCP();
@ -23,13 +23,12 @@ const UserHeader = ({ values }) => {
</div>
<PageHeaderWrapper content={
<div className={styles.pageHeaderContent}>
<div className={styles.avatar}>
<antd.Avatar shape="square" size="large" src={values.avatar} />
</div>
<div className={styles.content}>
<div className={styles.contentTitle}>
<h1 style={{ marginBottom: '0px' }} >{values.username}</h1>
<h1 style={{ marginBottom: '0px' }} >{values.username}<antd.Tooltip title="User Verified">{ycore.booleanFix(values.verified)? <antd.Icon style={{ color: 'blue', verticalAlign:'top' }} component={CustomIcons.VerifiedBadge} /> : null}</antd.Tooltip></h1>
<span style={{ fontSize: '14px', fontWeight: '100', lineHeight: '0', marginBottom: '5px' }}>{values.about}</span>
</div>
</div>
@ -37,7 +36,26 @@ const UserHeader = ({ values }) => {
} />
</div>
);
};
};
const UserBody = ({ values }) => {
try {
const feedParsed = JSON.parse(values)['data']
return (
feedParsed.map(item=> {
const {id, postText, post_time, publisher, postFile, postFileName} = item
const paylodd = {user: publisher.username, ago: post_time, avatar: publisher.avatar, content: postText, file: postFile, postFileName: postFileName, publisher: publisher }
ycore.DevOptions.ShowFunctionsLogs? console.log([item], paylodd) : null
return <PostCard payload={paylodd} key={id} />
})
)
} catch (err) {
const paylodd = {user: 'Error', ago: '', avatar: '', content: 'Error displaying data :/', publisher: '' }
return <PostCard payload={paylodd} />
}
}
class UserProfile extends React.Component {
constructor(props){
super(props),
@ -46,21 +64,22 @@ class UserProfile extends React.Component {
loading: true
}
}
componentDidMount(){
const { regx } = this.props
this.initUser(regx)
}
initUser = (e) => {
const parsed = e.shift()
const raw = parsed.toString()
const string = raw.replace('/@', "")
const selfProfile = { id: userData.id, username: userData.username, avatar: userData.avatar, about: userData.about }
isOwnProfile(e)? this.setState({RenderValue: selfProfile, loading: false}) : (
ycore.FindUser(string, (exception, response)=> {
isOwnProfile(e)? (
ycore.GetUserPosts(userData.id, (exception, response) => {
this.setState({ RenderValue: userData, rawbody: response, loading: false})
}))
:
(ycore.FindUser(string, (exception, response)=> {
exception? ycore.notifyError(exception) : null
try {
const rp = JSON.parse(response)
@ -77,21 +96,31 @@ class UserProfile extends React.Component {
console.log(`Using aproximate user! => ${c1} / ${c2}`)
ycore.crouter.native(`@${c1}`)
}
ycore.GetUserPosts(rp['0'].user_id, (exception, response) => {
exception? ycore.notifyError(exception) : null
try {
this.setState({ rawbody: response })
} catch (err) {
core.notifyError(err)
}
})
this.setState({ RenderValue: rp['0'], loading: false })
} catch (err) {
ycore.notifyError(err)
}
})
)
}
render(){
const { loading } = this.state
return(
<div>
{loading? <antd.Skeleton active /> : <UserHeader values={this.state.RenderValue} />}
{loading? <antd.Skeleton active /> :
(<div>
<UserHeader values={this.state.RenderValue} />
<UserBody values={this.state.rawbody} />
</div>)
}
</div>
)
}

View File

@ -3,12 +3,10 @@
.UserCover {
position: relative;
width: 100%;
margin: -32px auto 0 auto;
padding: 0;
margin: -32px auto auto auto;
overflow: hidden;
min-height: 366.1px;
max-height: 366.1px;
height: 366.1px;
max-height: 40%;
img{
width: 100%;
}
@ -49,6 +47,7 @@
}
.pageHeaderContent {
vertical-align: top;
display: flex;
.avatar {
flex: 0 1 72px;