diff --git a/globals/endpoints.js b/globals/endpoints.js
index 0ebc3ab6..7a3e9292 100755
--- a/globals/endpoints.js
+++ b/globals/endpoints.js
@@ -1,5 +1,6 @@
module.exports = {
Endpoints: {
+ comments_actions: "https://api.ragestudio.net/RSA-COMTY/r/comments?access_token=",
get_post_data: "https://api.ragestudio.net/RSA-COMTY/r/get-post-data?access_token=",
get_user_tags: "https://api.ragestudio.net/RSA-COMTY/r/user_tags?access_token=",
get_general_data: "https://api.ragestudio.net/RSA-COMTY/r/get-general-data?access_token=",
diff --git a/package.json b/package.json
index aafc5c12..9204122d 100755
--- a/package.json
+++ b/package.json
@@ -3,7 +3,7 @@
"UUID": "C8mVSr-4nmPp2-pr5Vrz-CU4kg4",
"title": "Comty™",
"DevBuild": true,
- "version": "0.2.23",
+ "version": "0.2.24",
"description": "",
"main": "app/main.js",
"author": "RageStudio",
@@ -20,7 +20,7 @@
"@lingui/react": "^2.9.1",
"@material-ui/core": "^4.9.3",
"@material-ui/icons": "^4.9.1",
- "antd": "^4.0.2",
+ "antd": "^4.0.4",
"axios": "^0.19.2",
"babel-core": "7.0.0-bridge.0",
"classnames": "^2.2.6",
@@ -49,6 +49,7 @@
"react-sound": "^1.2.0",
"react-virtualized": "^9.21.2",
"store": "^2.0.12",
+ "timeago.js": "^4.0.2",
"ts-cookies": "^1.0.0",
"umi-plugin-datahub": "^4.1.0",
"validator": "^12.2.0"
diff --git a/src/@ycore/libs.js b/src/@ycore/libs.js
index 42047ee9..1981f0bc 100755
--- a/src/@ycore/libs.js
+++ b/src/@ycore/libs.js
@@ -3,4 +3,6 @@ export * from './libs/comty_ng/pre.js';
export * from './libs/yulio_id/pre.js';
export * from './libs/ycore_styles/pre.js';
export * from './libs/ycore_sdcp/pre.js';
-export * from './libs/app_functions/pre.js'
\ No newline at end of file
+export * from './libs/app_functions/pre.js'
+
+
diff --git a/src/@ycore/libs/app_functions/pre.js b/src/@ycore/libs/app_functions/pre.js
index 46263819..98d43ba4 100644
--- a/src/@ycore/libs/app_functions/pre.js
+++ b/src/@ycore/libs/app_functions/pre.js
@@ -13,15 +13,11 @@ export const CheckThisApp = {
}
return false
},
-
}
export const SecondarySwap = {
- ext: ()=> {
- SwapMode.ext()
- },
- PostComments: (e) => {
- SwapMode.PostComments(e)
+ close: () => {
+ SwapMode.close()
},
openPost: (e) => {
SwapMode.openPost(e)
diff --git a/src/@ycore/libs/comty_ng/pre.js b/src/@ycore/libs/comty_ng/pre.js
index 31fae58f..bf664d7f 100755
--- a/src/@ycore/libs/comty_ng/pre.js
+++ b/src/@ycore/libs/comty_ng/pre.js
@@ -34,7 +34,56 @@ export const IsThisPost = {
}
}
+export const Post_Comments = {
+ delete: (callback, payload) => {
+ if (!payload) {
+ return false
+ }
+ const { comment_id } = payload
+ let formdata = new FormData();
+ formdata.append("type", "delete");
+ formdata.append("comment_id", comment_id);
+
+ API_Call((err,res)=> {
+ return callback(err,res)
+ },
+ ycore.endpoints.comments_actions,
+ formdata,
+ )
+ }
+}
+
+function API_Call(callback, endpoint, payload, options){
+ if (!payload || !endpoint) {
+ return false
+ }
+ let payloadContainer = payload;
+ payloadContainer.append("server_key", ycore.yConfig.server_key);
+ const defaultOptions = { method: "POST", timeout: 0, processData: false }
+ const { method, timeout, processData } = options || defaultOptions
+
+ const requestOptions = {
+ "url": `${endpoint}${ycore.handlerYIDT.__token()}`,
+ "method": method,
+ "timeout": timeout,
+ "data": payloadContainer,
+ "mimeType": "multipart/form-data",
+ "processData": processData,
+ "contentType": false
+ };
+
+ jquery.ajax(requestOptions)
+ .done(response => {
+ ycore.yconsole.log(response)
+ return callback(false, response)
+ })
+ .fail(error => {
+ ycore.yconsole.log('error', error)
+ ycore.Alive_API.fail(error)
+ return callback(true, error)
+ });
+}
export function GetGeneralData(callback){
let formdata = new FormData();
formdata.append("user_id", id);
@@ -52,6 +101,7 @@ export function GetGeneralData(callback){
})
.catch(error => {
console.log('error', error)
+ ycore.Alive_API.fail(error)
return callback(true, error)
});
}
@@ -73,6 +123,7 @@ export function follow_user(id, callback) {
return callback(false, response)
})
.catch(error => {
+ ycore.Alive_API.fail(error)
console.log('error', error)
return callback(true, error)
});
@@ -142,6 +193,7 @@ export function PublishPost(privacy, raw, file, callback){
})
.fail(error => {
ycore.yconsole.log('error', error)
+ ycore.Alive_API.fail(error)
return callback(true, error)
});
}
@@ -166,6 +218,7 @@ export function FindUser(key, callback){
})
.fail(function (response) {
const exception = 'API Bad response';
+ ycore.Alive_API.fail(response)
return callback(exception, response);
})
}
@@ -190,29 +243,30 @@ export function SeachKeywords(key, callback){
})
.fail(function (response) {
const exception = 'Request Failed';
+ ycore.Alive_API.fail(response)
return callback(exception, response);
})
}
export function ActionPost(type, id, value, callback){
- var formdata = new FormData();
- formdata.append("server_key", ycore.yConfig.server_key);
if (!type || !id) {
ycore.notifyError('[ActionPost] No type or id Provided !!!')
return false
}
+ var formdata = new FormData();
+ formdata.append("server_key", ycore.yConfig.server_key);
+ formdata.append("post_id", id);
switch (type) {
case 'like':
{
formdata.append("action", "like");
- formdata.append("post_id", id);
break
}
- case 'commet':
+ case 'comment':
{
if (!value) {
return false
}
- formdata.append("action", "commet");
+ formdata.append("action", "comment");
formdata.append("text", value)
break
}
@@ -228,7 +282,6 @@ export function ActionPost(type, id, value, callback){
case 'delete':
{
formdata.append("action", "delete");
- formdata.append("post_id", id);
break
}
default:
@@ -250,6 +303,7 @@ export function ActionPost(type, id, value, callback){
return callback(null, response);
})
.fail(function (response) {
+ ycore.Alive_API.fail(response)
return callback(true, `[Server error] We couldnt ${type} this post`);
})
}
@@ -277,6 +331,7 @@ export function GetUserTags(id, callback){
})
.fail(function (response) {
const exception = 'Request Failed';
+ ycore.Alive_API.fail(response)
return callback(exception, response);
})
}
@@ -313,6 +368,7 @@ export function GetPosts(userid, type, fkey, callback) {
})
.fail(function (response) {
const exception = 'Request Failed';
+ ycore.Alive_API.fail(response)
return callback(exception, response);
})
}
@@ -342,6 +398,7 @@ export function GetPostData(a, b, callback){
})
.fail(function (response) {
const exception = 'Request Failed';
+ ycore.Alive_API.fail(response)
return callback(exception, response);
})
}
diff --git a/src/@ycore/libs/yulio_id/pre.js b/src/@ycore/libs/yulio_id/pre.js
index 30e8e9b7..ad093839 100755
--- a/src/@ycore/libs/yulio_id/pre.js
+++ b/src/@ycore/libs/yulio_id/pre.js
@@ -11,6 +11,14 @@ var jwt = require("jsonwebtoken")
export function userData(){
return ycore.handlerYIDT.get()
}
+export const Alive_API = {
+ fail: (a) => {
+ if (a){
+ ycore.yconsole.log(a)
+ ycore.notify.error(a)
+ }
+ }
+}
function __API__User (payload, sdcp, callback){
const { UserID, UserToken } = payload
@@ -167,6 +175,9 @@ export function LogoutCall(){
ycore.handlerYIDT.remove()
ycore.router.push({pathname: '/login',})
})
+ .fail((response) => {
+ ycore.Alive_API.fail(response)
+ })
}
export function __AppSetup__(EncUsername, EncPassword, callback) {
const prefix = '[Auth Server]:';
@@ -221,8 +232,9 @@ export function __AppSetup__(EncUsername, EncPassword, callback) {
}
return;
})
- .fail(function (response) {
+ .fail(function (response) {
const exception = new Error("Server failed response . . . :( ");
+ ycore.Alive_API.fail(response)
return;
})
}
@@ -263,6 +275,7 @@ export function GetUserData (values, callback) {
.fail(
function (response) {
ycore.yconsole.log(prefix, 'Server failure!', response)
+ ycore.Alive_API.fail(response)
callback(true, response )
}
)
diff --git a/src/@ycore/ycore_worker.js b/src/@ycore/ycore_worker.js
index 6eb94176..14472816 100755
--- a/src/@ycore/ycore_worker.js
+++ b/src/@ycore/ycore_worker.js
@@ -5,12 +5,13 @@
* @licensed Pending...
*/
-import {ListSettings} from "../../globals/settings.js";
import {Endpoints} from "globals/endpoints.js";
import * as Icons from '@ant-design/icons';
import localforage from "localforage"
+import { format } from 'timeago.js';
import umiRouter from "umi/router";
import * as antd from "antd";
+import moment from 'moment'
import React from "react";
import config from "config"
@@ -65,6 +66,22 @@ export function b64toBlob(b64Data, contentType, sliceSize) {
var blob = new Blob(byteArrays, {type: contentType});
return blob;
}
+export const time = {
+ ago: (a) => {
+ const format = moment(a).format('DDMMYYYY');
+ const b = new Date(format).toLocaleString();
+ return time.relativeToNow(b);
+ },
+ stmToAgo: (a) => {
+ const b = (a*1000);
+ return format(b);
+ },
+ relativeToNow: (a, b) => {
+ return moment(a, b || "DDMMYYYY").fromNow();
+ }
+}
+
+
export function objectLast(array, n) {
if (array == null)
return void 0;
diff --git a/src/components/Layout/Secondary/index.js b/src/components/Layout/Secondary/index.js
index e2d37168..150cee36 100644
--- a/src/components/Layout/Secondary/index.js
+++ b/src/components/Layout/Secondary/index.js
@@ -5,27 +5,17 @@ import * as Icons from '@ant-design/icons'
import styles from './index.less'
import classnames from 'classnames'
-import SecRenderPost from './post'
+import {__priPost, __secComments} from './renders.js'
export const SwapMode = {
- ext: () => {
- SecondaryLayoutComponent.setState({
- swap: true,
- mode: 'ext'
- })
+ close: () => {
+ SecondaryLayoutComponent.closeSwap()
},
- PostComments: (e) => {
+ openPost: (a, b) => {
SecondaryLayoutComponent.setState({
swap: true,
- mode: 'post_comments',
- s_raw: e
- })
- },
- openPost: (e) => {
- SecondaryLayoutComponent.setState({
- swap: true,
- mode: 'open_post',
- s_raw: e
+ mode: 'post',
+ global_raw: a,
})
}
}
@@ -36,47 +26,68 @@ export default class Secondary extends React.PureComponent{
window.SecondaryLayoutComponent = this;
this.state = {
swap: false,
- mode: 'ext',
- s_raw: '',
+ mode: '',
+ global_raw: '',
+ pri_raw: '',
+ sec_raw: '',
}
}
+
closeSwap(){
this.setState({
swap: !this.state.swap,
- s_raw: null,
- mode: 'ext'
+ pri_raw: null,
+ sec_raw: null,
+ mode: ''
})
}
+
+ SwapBalanceContent(container){
+ switch (container){
+ case '__pri': {
+ return this.__pri()
+ }
+ case '__sec': {
+ return this.__sec()
+ }
+ default: return null
+ }
+ }
+
+ __pri(){
+ const dtraw = this.state.pri_raw;
+ switch (this.state.mode){
+ case 'post': {
+ return this.renderPost(this.state.global_raw)
+ }
+ default: return null
+ }
+ }
+ __sec(){
+ const dtraw = this.state.sec_raw;
+ switch (this.state.mode){
+ case 'post': {
+ return this.renderComments(this.state.global_raw)
+ }
+ default: return null
+ }
+ }
+
renderPost = (payload) => {
const post_data = JSON.parse(payload)['post_data']
console.log(post_data)
return(
-
{post_time} {ycore.IsThisUser.dev()? `| #${id}` : null}
-{post_time} {ycore.IsThisUser.dev()? `| #${id}` : null}
+@{publisher.username} {ycore.booleanFix(publisher.verified)?
e.preventDefault()} className={styles.comment_user_ago}>{ycore.time.stmToAgo(time)}
+{Orginaltext}
+