diff --git a/config/ycore.config.js b/config/ycore.config.js index 6731a78c..0a073f9d 100644 --- a/config/ycore.config.js +++ b/config/ycore.config.js @@ -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=", diff --git a/src/@ycore/ycore_worker.js b/src/@ycore/ycore_worker.js index e5f89cf7..9ac610aa 100644 --- a/src/@ycore/ycore_worker.js +++ b/src/@ycore/ycore_worker.js @@ -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 = { diff --git a/src/components/Layout/Header.js b/src/components/Layout/Header.js index ad1bfd1a..dcb47cf7 100644 --- a/src/components/Layout/Header.js +++ b/src/components/Layout/Header.js @@ -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 {
- + ycore.crouter.native('main')} style={{ fontSize: '15px' }} />
diff --git a/src/components/Layout/L_Sider.js b/src/components/Layout/L_Sider.js index 53bf8fa1..ebd67ebc 100644 --- a/src/components/Layout/L_Sider.js +++ b/src/components/Layout/L_Sider.js @@ -169,7 +169,7 @@ class L_Sider extends PureComponent {
- {collapsed? null :

@{userData.username}

} + {collapsed? null :

@{userData.username}

}
diff --git a/src/components/PostCard/index.js b/src/components/PostCard/index.js index 4ee5d237..6f0b5635 100644 --- a/src/components/PostCard/index.js +++ b/src/components/PostCard/index.js @@ -69,7 +69,7 @@ class PostCard extends React.PureComponent{ } - title={

@{user} {this.isVerifiedAccount(publisher)? : null}

} + title={

@{user} {this.isVerifiedAccount(publisher)? : null}

} description={{ago}} bordered="false" /> diff --git a/src/components/UserProfile/index.js b/src/components/UserProfile/index.js index fd9d84a1..eebbcfb9 100644 --- a/src/components/UserProfile/index.js +++ b/src/components/UserProfile/index.js @@ -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 }) => { -
-

{values.username}

+

{values.username}{ycore.booleanFix(values.verified)? : null}

{values.about}
@@ -37,7 +36,26 @@ const UserHeader = ({ values }) => { } /> ); - }; +}; +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 + }) + ) + } catch (err) { + const paylodd = {user: 'Error', ago: '', avatar: '', content: 'Error displaying data :/', publisher: '' } + return + } + + +} + 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(
- {loading? : } + {loading? : + (
+ + +
) + }
) } diff --git a/src/components/UserProfile/styles.less b/src/components/UserProfile/styles.less index 6f872e4d..73d5febf 100644 --- a/src/components/UserProfile/styles.less +++ b/src/components/UserProfile/styles.less @@ -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;