changed routes for posting

This commit is contained in:
ue 2018-10-23 16:14:59 +03:00
parent d53ab67740
commit c3c7aeb3fc
3 changed files with 16 additions and 28 deletions

View File

@ -13,7 +13,7 @@ import { SideMenu } from '../components';
const mainNavigation = DrawerNavigator(
{
[ROUTES.SCREENS.HOME]: {
screen: Editor,
screen: BaseNavigator,
navigationOptions: {
header: () => null,
},

View File

@ -7,6 +7,7 @@ import { getUserData } from '../../../realm/realm';
// Middleware
// Constants
import { default as ROUTES } from '../../../constants/routeNames';
// Utilities
import { generatePermlink } from '../../../utils/editor';
@ -32,6 +33,7 @@ class ExampleContainer extends Component {
// Component Functions
_submitPost = async (form) => {
const { navigation } = this.props;
let userData;
let postingKey;
const title = form.formFields['title-area'].content;
@ -49,16 +51,15 @@ class ExampleContainer extends Component {
author: userData.username,
permlink: permlink && permlink,
tags: form.tags,
// parent_author: 'u-e',
// parent_permlink: ' ',
};
postContent(post, postingKey)
.then((result) => {
alert(`Success${result}`);
alert('Your post succesfully shared');
navigation.navigate(ROUTES.SCREENS.HOME);
})
.catch((error) => {
alert(error);
alert(`Opps! there is a problem${error}`);
});
}
};

View File

@ -1,28 +1,15 @@
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) {
const re = /[^a-z0-9]+/gi;
const re2 = /^-*|-*$/g;
let permlink = text.replace(re, '-');
// 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;
// let permlink;
const re = /[^a-z0-9]+/gi; // global and case insensitive matching of non-char/non-numeric
const re2 = /^-*|-*$/g; // get rid of any leading/trailing dashes
let permlink = text.replace(re, '-'); // perform the 1st regexp
permlink = `${permlink.replace(re2, '').toLowerCase()}-id-${Math.random()
.toString(36)
.substr(2, 16)}`;
return permlink;
permlink = `${permlink.replace(re2, '').toLowerCase()}-id-${Math.random()
.toString(36)
.substr(2, 16)}`;
return permlink;
}
return null;
};