mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-11-29 22:07:46 +03:00
commit
5a2f9dd8ee
@ -38,8 +38,7 @@ export default class TagAreaView extends Component {
|
||||
|
||||
// Component Functions
|
||||
_handleOnChange = (text, i) => {
|
||||
this.setState({ currentText: text.replace(/\s/g, '').toLowerCase() });
|
||||
|
||||
this.setState({ currentText: text.replace(/\s/g, '') });
|
||||
if (text.indexOf(' ') > 0 && text) {
|
||||
this._handleTagAdded();
|
||||
}
|
||||
|
@ -291,7 +291,19 @@ class EditorContainer extends Component {
|
||||
const meta = extractMetadata(fields.body);
|
||||
const jsonMeta = makeJsonMetadata(meta, fields.tags);
|
||||
// TODO: check if permlink is available github: #314 https://github.com/esteemapp/esteem-mobile/pull/314
|
||||
const permlink = generatePermlink(fields.title);
|
||||
let permlink = generatePermlink(fields.title);
|
||||
|
||||
let dublicatePost;
|
||||
try {
|
||||
dublicatePost = await getPurePost(currentAccount.name, permlink);
|
||||
} catch (e) {
|
||||
dublicatePost = null;
|
||||
}
|
||||
|
||||
if (dublicatePost && dublicatePost.id) {
|
||||
permlink = generatePermlink(fields.title, true);
|
||||
}
|
||||
|
||||
const author = currentAccount.name;
|
||||
const options = makeOptions(author, permlink);
|
||||
const parentPermlink = fields.tags[0];
|
||||
|
@ -3,14 +3,16 @@ import { diff_match_patch } from 'diff-match-patch';
|
||||
|
||||
export const getWordsCount = text => (text && typeof text === 'string' ? text.replace(/^\s+|\s+$/g, '').split(/\s+/).length : 0);
|
||||
|
||||
export const generatePermlink = (title, random = false) => {
|
||||
if (title) {
|
||||
const slug = getSlug(title);
|
||||
let perm = slug.toString();
|
||||
const permlinkRnd = () => (Math.random() + 1).toString(16).substring(2);
|
||||
|
||||
export const generatePermlink = (title, random = false) => {
|
||||
const slug = getSlug(title);
|
||||
let perm = slug.toString();
|
||||
|
||||
if (title) {
|
||||
if (random) {
|
||||
const rnd = (Math.random() + 1).toString(16).substring(2);
|
||||
perm = `${slug.toString()}-${rnd}est`;
|
||||
perm = `${slug.toString()}${rnd}est`;
|
||||
}
|
||||
|
||||
// STEEMIT_MAX_PERMLINK_LENGTH
|
||||
@ -20,9 +22,13 @@ export const generatePermlink = (title, random = false) => {
|
||||
|
||||
// only letters numbers and dashes
|
||||
perm = perm.toLowerCase().replace(/[^a-z0-9-]+/g, '');
|
||||
return perm;
|
||||
|
||||
if (perm.length === 0) {
|
||||
return permlinkRnd();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
return perm;
|
||||
};
|
||||
|
||||
export const generateReplyPermlink = (toAuthor) => {
|
||||
|
Loading…
Reference in New Issue
Block a user