mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-11-30 14:54:12 +03:00
working on posting
This commit is contained in:
parent
710931fc1e
commit
22f66eb00d
@ -25,6 +25,10 @@ class EditorHeaderView extends Component {
|
||||
|
||||
// Component Functions
|
||||
|
||||
_handleOnPress = () => {
|
||||
this.props.handleOnSubmit();
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
handleOnPressBackButton,
|
||||
@ -32,6 +36,7 @@ class EditorHeaderView extends Component {
|
||||
isPreviewActive,
|
||||
quickTitle,
|
||||
isFormValid,
|
||||
handleSubmit,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
@ -61,6 +66,7 @@ class EditorHeaderView extends Component {
|
||||
styles.textButton,
|
||||
isFormValid ? styles.textButtonEnable : styles.textButtonDisable,
|
||||
]}
|
||||
onPress={this._handleOnPress}
|
||||
style={styles.textButtonWrapper}
|
||||
text="Publish"
|
||||
/>
|
||||
|
@ -1,15 +1,17 @@
|
||||
import React, { Component } from 'react';
|
||||
|
||||
// Services and Actions
|
||||
import { postContent } from '../../../providers/steem/dsteem';
|
||||
import { getUserData } from '../../../realm/realm';
|
||||
|
||||
// Middleware
|
||||
|
||||
// Constants
|
||||
|
||||
// Utilities
|
||||
// import { postContent } from '../../providers/steem/dsteem';
|
||||
// import { getUserData, getAuthStatus } from '../../realm/realm';
|
||||
// import { decryptKey } from '../../utils/crypto';
|
||||
import { generatePermlink } from '../../../utils/editor';
|
||||
import { decryptKey } from '../../../utils/crypto';
|
||||
|
||||
// Component
|
||||
import { EditorScreen } from '../screen/editorScreen';
|
||||
|
||||
@ -29,51 +31,38 @@ class ExampleContainer extends Component {
|
||||
|
||||
// Component Functions
|
||||
|
||||
// generatePermlink = () => {
|
||||
// let title;
|
||||
_submitPost = async () => {
|
||||
let userData;
|
||||
let postingKey;
|
||||
|
||||
// title = this.state.title
|
||||
// .replace(/[^\w\s]/gi, '')
|
||||
// .replace(/\s\s+/g, '-')
|
||||
// .replace(/\s/g, '-')
|
||||
// .toLowerCase();
|
||||
// title = `${title}-id-${Math.random()
|
||||
// .toString(36)
|
||||
// .substr(2, 16)}`;
|
||||
await getUserData().then((res) => {
|
||||
userData = Array.from(res);
|
||||
postingKey = decryptKey(userData[0].postingKey, '1234');
|
||||
});
|
||||
|
||||
// return title;
|
||||
// };
|
||||
const post = {
|
||||
body: this.state.body,
|
||||
title: this.state.title,
|
||||
author: userData[0].username,
|
||||
permlink: generatePermlink(),
|
||||
tags: this.state.tags,
|
||||
};
|
||||
|
||||
// submitPost = async () => {
|
||||
// let userData;
|
||||
// let postingKey;
|
||||
postContent(post, postingKey)
|
||||
.then((result) => {
|
||||
console.log(result);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
});
|
||||
};
|
||||
|
||||
// await getUserData().then((res) => {
|
||||
// userData = Array.from(res);
|
||||
// postingKey = decryptKey(userData[0].postingKey, 'pinCode');
|
||||
// });
|
||||
|
||||
// post = {
|
||||
// body: this.state.body,
|
||||
// title: this.state.title,
|
||||
// author: userData[0].username,
|
||||
// permlink: this.generatePermlink(),
|
||||
// tags: this.state.tags,
|
||||
// };
|
||||
|
||||
// console.log(post);
|
||||
|
||||
// postContent(post, postingKey)
|
||||
// .then((result) => {
|
||||
// console.log(result);
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// console.log(error);
|
||||
// });
|
||||
// };
|
||||
_handleSubmit = (form) => {
|
||||
alert(form);
|
||||
};
|
||||
|
||||
render() {
|
||||
return <EditorScreen />;
|
||||
return <EditorScreen handleOnSubmit={this._handleSubmit} />;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,14 @@ export class EditorScreen extends Component {
|
||||
}
|
||||
};
|
||||
|
||||
_handleOnSubmit = () => {};
|
||||
_handleOnSubmit = () => {
|
||||
const { handleOnSubmit } = this.props;
|
||||
const { formFields, tags } = this.state;
|
||||
|
||||
if (handleOnSubmit) {
|
||||
handleOnSubmit({ formFields, tags });
|
||||
}
|
||||
};
|
||||
|
||||
_handleIsFormValid = () => {
|
||||
const { formFields } = this.state;
|
||||
@ -79,10 +86,7 @@ export class EditorScreen extends Component {
|
||||
};
|
||||
|
||||
_handleOnTagAdded = (tags) => {
|
||||
this.setState({
|
||||
tags,
|
||||
});
|
||||
console.log(tags);
|
||||
this.setState({ tags });
|
||||
};
|
||||
|
||||
render() {
|
||||
@ -95,6 +99,7 @@ export class EditorScreen extends Component {
|
||||
quickTitle={wordsCount > 0 && `${wordsCount} words`}
|
||||
handleOnPressPreviewButton={this._handleOnPressPreviewButton}
|
||||
isFormValid={isFormValid}
|
||||
handleOnSubmit={this._handleOnSubmit}
|
||||
/>
|
||||
<PostForm
|
||||
handleFormUpdate={this._handleFormUpdate}
|
||||
|
@ -1 +1,19 @@
|
||||
export const getWordsCount = text => (text && typeof text === 'string' ? text.replace(/^\s+|\s+$/g, '').split(/\s+/).length : 0);
|
||||
|
||||
export const generatePermlink = (text) => {
|
||||
let permlink = null;
|
||||
|
||||
if (text) {
|
||||
permlink = text
|
||||
.replace(/[^\w\s]/gi, '')
|
||||
.replace(/\s\s+/g, '-')
|
||||
.replace(/\s/g, '-')
|
||||
.toLowerCase();
|
||||
|
||||
permlink = `${text}-id-${Math.random()
|
||||
.toString(36)
|
||||
.substr(2, 16)}`;
|
||||
}
|
||||
|
||||
return permlink;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user