mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-11-28 01:52:56 +03:00
fixed #closed #435
This commit is contained in:
parent
842d90e522
commit
31c53c59a3
@ -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,11 +3,13 @@ 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`;
|
||||
@ -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