Merge pull request #873 from esteemapp/bugfix/postUpdate

updated post update functions
This commit is contained in:
uğur erdal 2019-05-25 14:56:36 +03:00 committed by GitHub
commit 8ee7d4b702
9 changed files with 35 additions and 39 deletions

View File

@ -430,7 +430,7 @@ THE SOFTWARE.
## SSZipArchive
Copyright (c) 2010-2015, Sam Soffes, https://soff.es
Copyright (c) 2010-2015, Sam Soffes, http://soff.es
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the

View File

@ -513,7 +513,7 @@ THE SOFTWARE.
</dict>
<dict>
<key>FooterText</key>
<string>Copyright (c) 2010-2015, Sam Soffes, https://soff.es
<string>Copyright (c) 2010-2015, Sam Soffes, http://soff.es
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the

View File

@ -3,7 +3,7 @@ GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Base64" "${PODS_ROOT}/Headers/Public/CodePush" "${PODS_ROOT}/Headers/Public/DoubleConversion" "${PODS_ROOT}/Headers/Public/FLAnimatedImage" "${PODS_ROOT}/Headers/Public/JWT" "${PODS_ROOT}/Headers/Public/QBImagePickerController" "${PODS_ROOT}/Headers/Public/RNImageCropPicker" "${PODS_ROOT}/Headers/Public/RSKImageCropper" "${PODS_ROOT}/Headers/Public/React" "${PODS_ROOT}/Headers/Public/SDWebImage" "${PODS_ROOT}/Headers/Public/SSZipArchive" "${PODS_ROOT}/Headers/Public/glog" "${PODS_ROOT}/Headers/Public/react-native-fast-image" "${PODS_ROOT}/Headers/Public/react-native-version-number" "${PODS_ROOT}/Headers/Public/yoga"
LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Base64" "${PODS_CONFIGURATION_BUILD_DIR}/CodePush" "${PODS_CONFIGURATION_BUILD_DIR}/DoubleConversion" "${PODS_CONFIGURATION_BUILD_DIR}/FLAnimatedImage" "${PODS_CONFIGURATION_BUILD_DIR}/Folly" "${PODS_CONFIGURATION_BUILD_DIR}/JWT" "${PODS_CONFIGURATION_BUILD_DIR}/QBImagePickerController" "${PODS_CONFIGURATION_BUILD_DIR}/RNImageCropPicker" "${PODS_CONFIGURATION_BUILD_DIR}/RSKImageCropper" "${PODS_CONFIGURATION_BUILD_DIR}/React" "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage" "${PODS_CONFIGURATION_BUILD_DIR}/SSZipArchive" "${PODS_CONFIGURATION_BUILD_DIR}/glog" "${PODS_CONFIGURATION_BUILD_DIR}/react-native-fast-image" "${PODS_CONFIGURATION_BUILD_DIR}/react-native-version-number" "${PODS_CONFIGURATION_BUILD_DIR}/yoga"
OTHER_CFLAGS = $(inherited) -fmodule-map-file="${PODS_ROOT}/Headers/Public/SSZipArchive/SSZipArchive.modulemap"
OTHER_LDFLAGS = $(inherited) -ObjC -l"Base64" -l"CodePush" -l"DoubleConversion" -l"FLAnimatedImage" -l"Folly" -l"JWT" -l"QBImagePickerController" -l"RNImageCropPicker" -l"RSKImageCropper" -l"React" -l"SDWebImage" -l"SSZipArchive" -l"c++" -l"glog" -l"iconv" -l"react-native-fast-image" -l"react-native-version-number" -l"sqlite3" -l"stdc++" -l"yoga" -l"z" -framework "AppCenter" -framework "AppCenterAnalytics" -framework "AppCenterCrashes" -framework "AppCenterPush" -framework "AppCenterReactNativeShared" -framework "CoreGraphics" -framework "CoreTelephony" -framework "Foundation" -framework "ImageIO" -framework "JavaScriptCore" -framework "MobileCoreServices" -framework "Photos" -framework "QuartzCore" -framework "Security" -framework "SystemConfiguration" -framework "UIKit" -weak_framework "UserNotifications"
OTHER_LDFLAGS = $(inherited) -ObjC -l"Base64" -l"CodePush" -l"DoubleConversion" -l"FLAnimatedImage" -l"Folly" -l"JWT" -l"QBImagePickerController" -l"RNImageCropPicker" -l"RSKImageCropper" -l"React" -l"SDWebImage" -l"SSZipArchive" -l"c++" -l"glog" -l"react-native-fast-image" -l"react-native-version-number" -l"sqlite3" -l"stdc++" -l"yoga" -l"z" -framework "AppCenter" -framework "AppCenterAnalytics" -framework "AppCenterCrashes" -framework "AppCenterPush" -framework "AppCenterReactNativeShared" -framework "CoreGraphics" -framework "CoreTelephony" -framework "Foundation" -framework "ImageIO" -framework "JavaScriptCore" -framework "MobileCoreServices" -framework "Photos" -framework "QuartzCore" -framework "Security" -framework "SystemConfiguration" -framework "UIKit" -weak_framework "UserNotifications"
OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS -Xcc -fmodule-map-file="${PODS_ROOT}/Headers/Public/SSZipArchive/SSZipArchive.modulemap"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)

View File

@ -3,7 +3,7 @@ GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Base64" "${PODS_ROOT}/Headers/Public/CodePush" "${PODS_ROOT}/Headers/Public/DoubleConversion" "${PODS_ROOT}/Headers/Public/FLAnimatedImage" "${PODS_ROOT}/Headers/Public/JWT" "${PODS_ROOT}/Headers/Public/QBImagePickerController" "${PODS_ROOT}/Headers/Public/RNImageCropPicker" "${PODS_ROOT}/Headers/Public/RSKImageCropper" "${PODS_ROOT}/Headers/Public/React" "${PODS_ROOT}/Headers/Public/SDWebImage" "${PODS_ROOT}/Headers/Public/SSZipArchive" "${PODS_ROOT}/Headers/Public/glog" "${PODS_ROOT}/Headers/Public/react-native-fast-image" "${PODS_ROOT}/Headers/Public/react-native-version-number" "${PODS_ROOT}/Headers/Public/yoga"
LIBRARY_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Base64" "${PODS_CONFIGURATION_BUILD_DIR}/CodePush" "${PODS_CONFIGURATION_BUILD_DIR}/DoubleConversion" "${PODS_CONFIGURATION_BUILD_DIR}/FLAnimatedImage" "${PODS_CONFIGURATION_BUILD_DIR}/Folly" "${PODS_CONFIGURATION_BUILD_DIR}/JWT" "${PODS_CONFIGURATION_BUILD_DIR}/QBImagePickerController" "${PODS_CONFIGURATION_BUILD_DIR}/RNImageCropPicker" "${PODS_CONFIGURATION_BUILD_DIR}/RSKImageCropper" "${PODS_CONFIGURATION_BUILD_DIR}/React" "${PODS_CONFIGURATION_BUILD_DIR}/SDWebImage" "${PODS_CONFIGURATION_BUILD_DIR}/SSZipArchive" "${PODS_CONFIGURATION_BUILD_DIR}/glog" "${PODS_CONFIGURATION_BUILD_DIR}/react-native-fast-image" "${PODS_CONFIGURATION_BUILD_DIR}/react-native-version-number" "${PODS_CONFIGURATION_BUILD_DIR}/yoga"
OTHER_CFLAGS = $(inherited) -fmodule-map-file="${PODS_ROOT}/Headers/Public/SSZipArchive/SSZipArchive.modulemap"
OTHER_LDFLAGS = $(inherited) -ObjC -l"Base64" -l"CodePush" -l"DoubleConversion" -l"FLAnimatedImage" -l"Folly" -l"JWT" -l"QBImagePickerController" -l"RNImageCropPicker" -l"RSKImageCropper" -l"React" -l"SDWebImage" -l"SSZipArchive" -l"c++" -l"glog" -l"iconv" -l"react-native-fast-image" -l"react-native-version-number" -l"sqlite3" -l"stdc++" -l"yoga" -l"z" -framework "AppCenter" -framework "AppCenterAnalytics" -framework "AppCenterCrashes" -framework "AppCenterPush" -framework "AppCenterReactNativeShared" -framework "CoreGraphics" -framework "CoreTelephony" -framework "Foundation" -framework "ImageIO" -framework "JavaScriptCore" -framework "MobileCoreServices" -framework "Photos" -framework "QuartzCore" -framework "Security" -framework "SystemConfiguration" -framework "UIKit" -weak_framework "UserNotifications"
OTHER_LDFLAGS = $(inherited) -ObjC -l"Base64" -l"CodePush" -l"DoubleConversion" -l"FLAnimatedImage" -l"Folly" -l"JWT" -l"QBImagePickerController" -l"RNImageCropPicker" -l"RSKImageCropper" -l"React" -l"SDWebImage" -l"SSZipArchive" -l"c++" -l"glog" -l"react-native-fast-image" -l"react-native-version-number" -l"sqlite3" -l"stdc++" -l"yoga" -l"z" -framework "AppCenter" -framework "AppCenterAnalytics" -framework "AppCenterCrashes" -framework "AppCenterPush" -framework "AppCenterReactNativeShared" -framework "CoreGraphics" -framework "CoreTelephony" -framework "Foundation" -framework "ImageIO" -framework "JavaScriptCore" -framework "MobileCoreServices" -framework "Photos" -framework "QuartzCore" -framework "Security" -framework "SystemConfiguration" -framework "UIKit" -weak_framework "UserNotifications"
OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS -Xcc -fmodule-map-file="${PODS_ROOT}/Headers/Public/SSZipArchive/SSZipArchive.modulemap"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)

View File

@ -2,7 +2,7 @@ FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/AppCenter/AppCenter-SDK-Appl
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Base64" "${PODS_ROOT}/Headers/Public/CodePush" "${PODS_ROOT}/Headers/Public/DoubleConversion" "${PODS_ROOT}/Headers/Public/FLAnimatedImage" "${PODS_ROOT}/Headers/Public/JWT" "${PODS_ROOT}/Headers/Public/QBImagePickerController" "${PODS_ROOT}/Headers/Public/RNImageCropPicker" "${PODS_ROOT}/Headers/Public/RSKImageCropper" "${PODS_ROOT}/Headers/Public/React" "${PODS_ROOT}/Headers/Public/SDWebImage" "${PODS_ROOT}/Headers/Public/SSZipArchive" "${PODS_ROOT}/Headers/Public/glog" "${PODS_ROOT}/Headers/Public/react-native-fast-image" "${PODS_ROOT}/Headers/Public/react-native-version-number" "${PODS_ROOT}/Headers/Public/yoga"
OTHER_CFLAGS = $(inherited) -fmodule-map-file="${PODS_ROOT}/Headers/Public/SSZipArchive/SSZipArchive.modulemap"
OTHER_LDFLAGS = $(inherited) -ObjC -l"c++" -l"iconv" -l"sqlite3" -l"stdc++" -l"z" -framework "CoreGraphics" -framework "CoreTelephony" -framework "Foundation" -framework "ImageIO" -framework "JavaScriptCore" -framework "MobileCoreServices" -framework "Photos" -framework "QuartzCore" -framework "Security" -framework "SystemConfiguration" -framework "UIKit"
OTHER_LDFLAGS = $(inherited) -ObjC -l"c++" -l"sqlite3" -l"stdc++" -l"z" -framework "CoreGraphics" -framework "CoreTelephony" -framework "Foundation" -framework "ImageIO" -framework "JavaScriptCore" -framework "MobileCoreServices" -framework "Photos" -framework "QuartzCore" -framework "Security" -framework "SystemConfiguration" -framework "UIKit"
OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS -Xcc -fmodule-map-file="${PODS_ROOT}/Headers/Public/SSZipArchive/SSZipArchive.modulemap"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)

View File

@ -2,7 +2,7 @@ FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/AppCenter/AppCenter-SDK-Appl
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/Base64" "${PODS_ROOT}/Headers/Public/CodePush" "${PODS_ROOT}/Headers/Public/DoubleConversion" "${PODS_ROOT}/Headers/Public/FLAnimatedImage" "${PODS_ROOT}/Headers/Public/JWT" "${PODS_ROOT}/Headers/Public/QBImagePickerController" "${PODS_ROOT}/Headers/Public/RNImageCropPicker" "${PODS_ROOT}/Headers/Public/RSKImageCropper" "${PODS_ROOT}/Headers/Public/React" "${PODS_ROOT}/Headers/Public/SDWebImage" "${PODS_ROOT}/Headers/Public/SSZipArchive" "${PODS_ROOT}/Headers/Public/glog" "${PODS_ROOT}/Headers/Public/react-native-fast-image" "${PODS_ROOT}/Headers/Public/react-native-version-number" "${PODS_ROOT}/Headers/Public/yoga"
OTHER_CFLAGS = $(inherited) -fmodule-map-file="${PODS_ROOT}/Headers/Public/SSZipArchive/SSZipArchive.modulemap"
OTHER_LDFLAGS = $(inherited) -ObjC -l"c++" -l"iconv" -l"sqlite3" -l"stdc++" -l"z" -framework "CoreGraphics" -framework "CoreTelephony" -framework "Foundation" -framework "ImageIO" -framework "JavaScriptCore" -framework "MobileCoreServices" -framework "Photos" -framework "QuartzCore" -framework "Security" -framework "SystemConfiguration" -framework "UIKit"
OTHER_LDFLAGS = $(inherited) -ObjC -l"c++" -l"sqlite3" -l"stdc++" -l"z" -framework "CoreGraphics" -framework "CoreTelephony" -framework "Foundation" -framework "ImageIO" -framework "JavaScriptCore" -framework "MobileCoreServices" -framework "Photos" -framework "QuartzCore" -framework "Security" -framework "SystemConfiguration" -framework "UIKit"
OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS -Xcc -fmodule-map-file="${PODS_ROOT}/Headers/Public/SSZipArchive/SSZipArchive.modulemap"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)

View File

@ -1,4 +1,3 @@
/* eslint-disable camelcase */
import { Client, PrivateKey } from 'dsteem';
import steemConnect from 'steemconnect';
import Config from 'react-native-config';
@ -356,19 +355,6 @@ export const getPurePost = async (author, permlink) => {
}
};
// export const deleteComment = (author, permlink) => {
// return new Promise((resolve, reject) => {
// client.database
// .call('delete_comment', [author, permlink])
// .then((response) => {
// resolve(response);
// })
// .catch((error) => {
// reject(error);
// });
// });
// };
export const deleteComment = (currentAccount, pin, permlink) => {
const { name: author } = currentAccount;
const digitPinCode = getDigitPinCode(pin);

View File

@ -22,6 +22,7 @@ import {
makeOptions,
extractMetadata,
makeJsonMetadataReply,
makeJsonMetadataForUpdate,
createPatch,
} from '../../../utils/editor';
// import { generateSignature } from '../../../utils/image';
@ -149,8 +150,6 @@ class EditorContainer extends Component {
}
};
// Media select functions <- START ->
_handleOpenImagePicker = () => {
ImagePicker.openPicker({
includeBase64: true,
@ -414,38 +413,39 @@ class EditorContainer extends Component {
const { post } = this.state;
if (currentAccount) {
this.setState({ isPostSending: true });
const { tags, body, title } = fields;
const {
body: oldBody,
parent_permlink: parentPermlink,
permlink,
parent_author: parentAuthor,
json_metadata: oldMeta,
json_metadata: jsonMetadata,
} = post;
let newBody = fields.body;
let _oldMeta = oldMeta;
let newBody = body;
const patch = createPatch(oldBody, newBody.trim());
if (patch && patch.length < Buffer.from(oldBody, 'utf-8').length) {
newBody = patch;
}
if (typeof _oldMeta === 'string') {
_oldMeta = JSON.parse(_oldMeta);
}
const meta = extractMetadata(fields.body);
const metadata = Object.assign({}, _oldMeta, meta);
const jsonMeta = makeJsonMetadata(metadata, fields.tags);
let jsonMeta = {};
try {
const oldJson = JSON.parse(jsonMetadata);
jsonMeta = makeJsonMetadataForUpdate(oldJson, meta, tags);
} catch (e) {
jsonMeta = makeJsonMetadata(meta, tags);
}
await postContent(
currentAccount,
pinCode,
parentAuthor || '',
'',
parentPermlink,
permlink,
fields.title,
title,
newBody,
jsonMeta,
)

View File

@ -1,5 +1,8 @@
import getSlug from 'speakingurl';
import { diff_match_patch } from 'diff-match-patch';
import { diff_match_patch as diffMatchPatch } from 'diff-match-patch';
import PackageJson from '../../../../package.json';
const { version } = PackageJson;
export const getWordsCount = text =>
text && typeof text === 'string' ? text.replace(/^\s+|\s+$/g, '').split(/\s+/).length : 0;
@ -87,7 +90,7 @@ export const makeOptions = (author, permlink, operationType) => {
export const makeJsonMetadataReply = tags => ({
tags,
app: 'esteem/2.0.0-mobile',
app: `esteem/${version}-mobile`,
format: 'markdown+html',
community: 'esteem.app',
});
@ -95,11 +98,18 @@ export const makeJsonMetadataReply = tags => ({
export const makeJsonMetadata = (meta, tags) =>
Object.assign({}, meta, {
tags,
app: 'esteem/2.0.0-mobile',
app: `esteem/${version}-mobile`,
format: 'markdown+html',
community: 'esteem.app',
});
export const makeJsonMetadataForUpdate = (oldJson, meta, tags) => {
const { meta: oldMeta } = oldJson;
const mergedMeta = Object.assign({}, oldMeta, meta);
return Object.assign({}, oldJson, mergedMeta, { tags });
};
export const extractMetadata = body => {
const urlReg = /(\b(https?|ftp):\/\/[A-Z0-9+&@#/%?=~_|!:,.;-]*[-A-Z0-9+&@#/%=~_|])/gim;
const userReg = /(^|\s)(@[a-z][-.a-z\d]+[a-z\d])/gim;
@ -148,7 +158,7 @@ export const extractMetadata = body => {
export const createPatch = (text1, text2) => {
if (!text1 && text1 === '') return undefined;
const dmp = new diff_match_patch();
const dmp = new diffMatchPatch();
const patches = dmp.patch_make(text1, text2);
const patch = dmp.patch_toText(patches);