diff --git a/config/ycore.config.js b/config/ycore.config.js index 22942ed1..6731a78c 100644 --- a/config/ycore.config.js +++ b/config/ycore.config.js @@ -26,6 +26,7 @@ module.exports = { openwheater_apiKey:'2acf34be0b8f033b89ba4de1e674d42a', }, Endpoints: { + 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=", auth_endpoint: "https://api.ragestudio.net/RS-YIBTP/yid/auth", diff --git a/src/@ycore/ycore_worker.js b/src/@ycore/ycore_worker.js index 4281961b..e5f89cf7 100644 --- a/src/@ycore/ycore_worker.js +++ b/src/@ycore/ycore_worker.js @@ -1,3 +1,5 @@ +import { cloneDeep, isString, flow, curry } from 'lodash'; +import umiRouter from 'umi/router'; import Cookies from "ts-cookies"; import axios from "axios"; import {SetControls, CloseControls} from ".././components/Layout/Control" @@ -39,6 +41,17 @@ export const UIFxList = { notifySuccess: (ycore_worker.FXapiProvider + 'notifySuccess.wav') }; +export const crouter = { + native: (e) =>{ + umiRouter.push({ + pathname: `/${e}`, + search: window.location.search, + }); + }, + default: (e) =>{ + router.push(e) + } +} export function notifyError(err){ antd.notification.error({ @@ -54,6 +67,56 @@ export function notifyProccess(cust){ placement: 'bottomLeft' }) } + +export function FindUser(key, callback){ + let formdata = new FormData(); + formdata.append("server_key", yConfig.server_key); + formdata.append("search_key", key); + const urlOBJ = `${endpoints.find_user}${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 = 'API Bad response'; + return callback(exception, response); + }); +} + +export function SeachKeywords(key, callback){ + let formdata = new FormData(); + formdata.append("server_key", yConfig.server_key); + formdata.append("search_key", key); + const urlOBJ = `${endpoints.search_endpoint}${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(); formdata.append("server_key", yConfig.server_key); @@ -72,6 +135,7 @@ export function GetFeedPosts(callback) { return callback( null, result) }) .catch(error => console.log('error', error)); + } diff --git a/src/components/Layout/Header.less b/src/components/Layout/Header.less index b8bab351..3a21a945 100644 --- a/src/components/Layout/Header.less +++ b/src/components/Layout/Header.less @@ -46,14 +46,14 @@ z-index: 10; transition: width 0.2s; right: 0; + transition: all 0.2s ease; &.collapsed { width: ~'calc(100% - 180px)'; - background-color: rgb(80, 80, 80); background-color: @LDarkMode-backgroud; color: @DarkMode-color; border-color: transparent; box-shadow: none; - transition: box-shadow 1s linear; + transition: all 0.2s ease; } :global { diff --git a/src/components/Layout/L_Sider.js b/src/components/Layout/L_Sider.js index 01ac8192..53bf8fa1 100644 --- a/src/components/Layout/L_Sider.js +++ b/src/components/Layout/L_Sider.js @@ -97,6 +97,7 @@ class L_Sider extends PureComponent { breakpoint="lg" trigger={null} collapsible + defaultCollapsed="false" onBreakpoint={isMobile ? null : onCollapseChange} collapsedWidth={this.Balancer()? "35" : "90"} theme={this.StrictMode()} diff --git a/src/components/UserProfile/index.js b/src/components/UserProfile/index.js index 79d1a2e8..fd9d84a1 100644 --- a/src/components/UserProfile/index.js +++ b/src/components/UserProfile/index.js @@ -9,26 +9,33 @@ const userData = ycore.SDCP(); function isOwnProfile(id){ if(id == userData.username){ + console.log('Is your own profile !!') return true } return false } -const UserHeader = ({ inputIO }) => { +const UserHeader = ({ values }) => { return ( - -
- -
-
-
-

{inputIO.username}

- {userData.about} +
+
+ +
+ + +
+ +
+
+
+

{values.username}

+ {values.about} +
-
- } /> + } /> +
); }; class UserProfile extends React.Component { @@ -36,33 +43,55 @@ class UserProfile extends React.Component { super(props), this.state = { RenderValue: {}, + 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 uservalue = { id: '', userToken: userData.userToken } - // ycore.GetUserData() - let rendVal = { id: '0', username: string, avatar: '' } - this.setState({ RenderValue: rendVal}) - console.log(`User => ${string} `) + 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)=> { + exception? ycore.notifyError(exception) : null + try { + const rp = JSON.parse(response) + ycore.DevOptions.ShowFunctionsLogs? console.log(rp) : null + if (!rp['0']) { + ycore.DevOptions.ShowFunctionsLogs? console.log('Bad response / User not found') : null + const val = { id: null, username: 'User not found!'} + this.setState({ RenderValue: val, loading: false }) + return + } + const c1 = rp['0'].username.toLowerCase() + const c2 = string.toLowerCase() + if (c1 !== c2) { + console.log(`Using aproximate user! => ${c1} / ${c2}`) + ycore.crouter.native(`@${c1}`) + } + + this.setState({ RenderValue: rp['0'], loading: false }) + } catch (err) { + ycore.notifyError(err) + } + }) + ) } render(){ - const { regx } = this.props; - console.log( regx ) + const { loading } = this.state return(
- {isOwnProfile(regx)?

Your profile

: null} - + {loading? : }
) } diff --git a/src/components/UserProfile/styles.less b/src/components/UserProfile/styles.less index fd4943c6..6f872e4d 100644 --- a/src/components/UserProfile/styles.less +++ b/src/components/UserProfile/styles.less @@ -1,5 +1,19 @@ @import '~themes/default'; +.UserCover { + position: relative; + width: 100%; + margin: -32px auto 0 auto; + padding: 0; + overflow: hidden; + min-height: 366.1px; + max-height: 366.1px; + height: 366.1px; + img{ + width: 100%; + } +} + .textOverflow() { overflow: hidden; white-space: nowrap; diff --git a/src/layouts/PrimaryLayout.js b/src/layouts/PrimaryLayout.js index 191aa762..47503904 100644 --- a/src/layouts/PrimaryLayout.js +++ b/src/layouts/PrimaryLayout.js @@ -22,6 +22,7 @@ class PrimaryLayout extends PureComponent { constructor(props){ super(props) this.state = { + collapsed: store.get('collapsed') || false, isMobile: false, resbypass: store.get('resbypass') || false, RemByPass: false, @@ -48,11 +49,10 @@ class PrimaryLayout extends PureComponent { unenquireScreen(this.enquireHandler) } - onCollapseChange = collapsed => { - this.props.dispatch({ - type: 'app/handleCollapseChange', - payload: collapsed, - }) + onCollapseChange = () => { + this.setState({ collapsed: !this.state.collapsed }) + store.set('collapsed', this.state.collapsed) + } ResByPassHandler() { @@ -76,8 +76,8 @@ class PrimaryLayout extends PureComponent { render() { const { app, location, dispatch, children } = this.props - const { theme, routeList, collapsed, notifications } = app - const { isMobile, resbypass, rememberbypass } = this.state + const { theme, routeList, notifications } = app + const { isMobile, resbypass, collapsed ,rememberbypass } = this.state const { onCollapseChange } = this // Localized route name. const lang = langFromPath(location.pathname) diff --git a/src/models/app.js b/src/models/app.js index a70aaa1c..4cb22a15 100644 --- a/src/models/app.js +++ b/src/models/app.js @@ -27,7 +27,6 @@ export default { AppSettings: store.get('app_settings') || config.defaultSettings, locationQuery: {}, theme: store.get('theme') || 'light', - collapsed: store.get('collapsed') || false, notifications: [ { title: 'Hey! Test notification', @@ -120,11 +119,6 @@ export default { state.theme = payload }, - handleCollapseChange(state, { payload }) { - store.set('collapsed', payload) - state.collapsed = payload - }, - allNotificationsRead(state) { state.notifications = [] }, diff --git a/src/pages/main/index.js b/src/pages/main/index.js index 8b573650..868c9ba7 100644 --- a/src/pages/main/index.js +++ b/src/pages/main/index.js @@ -43,14 +43,23 @@ class Main extends React.Component { } } + getTarget = () => document.getElementById("PostsWrapper") render(){ - const { loading, createPost } = this.state; - console.log('createPost =>', createPost) + const target = this.getTarget(); + const { loading, createPost } = this.state; return (
+ {createPost? {this.handleRefreshList()}} /> : null} - {loading? :
{this.renderFeedPosts()}
} + {loading? + + + : +
+ document.getElementById("PostsWrapper") } /> + {this.renderFeedPosts()} +
}
) } diff --git a/src/pages/main/index.less b/src/pages/main/index.less index 93277c01..32f8d0b3 100644 --- a/src/pages/main/index.less +++ b/src/pages/main/index.less @@ -2,5 +2,11 @@ margin: auto; align-content: center; align-items: center; + :global { + .ant-back-top { + position: absolute; + z-index: 100000000; + } + } } \ No newline at end of file diff --git a/src/pages/s/$search/index.js b/src/pages/s/$search/index.js index 5d1b59d8..01bb29c3 100644 --- a/src/pages/s/$search/index.js +++ b/src/pages/s/$search/index.js @@ -1,5 +1,4 @@ import React, { PureComponent } from 'react' -import { UserProfile } from 'components' import { pathMatchRegexp } from 'utils' import styles from './styles.less' import * as ycore from 'ycore' @@ -14,24 +13,24 @@ class SearchPageIndexer extends PureComponent { SearchResult: '' } } - SeachKeywords(key){ - let formdata = new FormData(); - formdata.append("server_key", ycore.yConfig.server_key); - formdata.append("search_key", key); - const requestOptions = { - method: 'POST', - body: formdata, + + componentDidMount(){ + try { + const {location} = this.props + const matchSearch = pathMatchRegexp("/s/:id", location.pathname); + const parsed = matchSearch.shift() + const raw = parsed.toString() + const string = raw.replace('/s/', "") + ycore.SeachKeywords(string, (exception, response) => { + console.log(response) + exception? ycore.notifyError(exception) : null + this.setState({ SearchResult: response }) + }) + + } catch (err) { + ycore.notifyError(err) } - const uriObj = (`${ycore.endpoints.search_endpoint}${ycore.GetUserToken.decrypted().UserToken}`) - fetch(uriObj, requestOptions) - .then(result => { - console.log(result) - this.setState({ SearchResult: result }) - - }) - .catch(error => console.log('error', error)); } - render() { const {location} = this.props @@ -43,7 +42,7 @@ class SearchPageIndexer extends PureComponent { if (matchSearch) { - this.SeachKeywords(string) + console.log(`Search matched! ${location.pathname}`) return(