...
|
...
|
@@ -34,6 +34,51 @@ const { |
|
|
|
|
|
let POSTING_CACHE_KEY = 'cachedPosting';
|
|
|
|
|
|
export function voidImplementationFunc() {
|
|
|
return {
|
|
|
type:'null',
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function startEditPost(postingState) {
|
|
|
|
|
|
return dispatch => {
|
|
|
console.log('lalala');
|
|
|
dispatch(voidImplementationFunc());
|
|
|
dispatch(() => {
|
|
|
console.log('nononononon');
|
|
|
if (postingState) {
|
|
|
Alert.alert('抱歉','您有正在发送的帖子,请耐心等待~');
|
|
|
} else {
|
|
|
NativeModules.YH_CommunityHelper.uid()
|
|
|
.then(uid => {
|
|
|
drillToEditPostPage(uid);
|
|
|
})
|
|
|
.catch(error => {
|
|
|
ReactNative.NativeModules.YH_CommunityHelper.login()
|
|
|
.then(uid => {
|
|
|
drillToEditPostPage(uid);
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
function drillToEditPostPage(uid,postingPageFunc) {
|
|
|
new PostingService().getPostUser(uid).then(json => {
|
|
|
if (json.forbidSpeaking === 'Y') {
|
|
|
Alert.alert('抱歉','您暂时被禁言,请等待禁言解除哦~');
|
|
|
} else {
|
|
|
Actions.Posting();
|
|
|
}
|
|
|
}).catch(error => {
|
|
|
Actions.Posting();
|
|
|
})
|
|
|
}
|
|
|
|
|
|
export function commitMerge(cachedObj) {
|
|
|
return {
|
|
|
type: POSTING_STATE_MERGE,
|
...
|
...
|
@@ -42,12 +87,17 @@ export function commitMerge(cachedObj) { |
|
|
}
|
|
|
|
|
|
export function mergeCachedPosting() {
|
|
|
return dispatch => store.get(POSTING_CACHE_KEY).then(cachedObj=>{
|
|
|
if (cachedObj) {
|
|
|
dispatch(commitMerge(cachedObj));
|
|
|
dispatch(startPosting(cachedObj.assets));
|
|
|
}
|
|
|
})
|
|
|
return dispatch => {
|
|
|
store.get(POSTING_CACHE_KEY)
|
|
|
.then((cachedObj)=>{
|
|
|
console.log('2222222222222222222222222');
|
|
|
console.log(cachedObj);
|
|
|
if (cachedObj) {
|
|
|
dispatch(commitMerge(cachedObj));
|
|
|
dispatch(startPosting(cachedObj.assets));
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
...
|
...
|
@@ -147,7 +197,7 @@ export function updateUploadState(url,fileName) { |
|
|
contentData: encodeURI(posting.content),
|
|
|
images: imageStr,
|
|
|
}
|
|
|
return new PostingService().commitPost(param).then(json => {
|
|
|
return new PostingService().commitPost(param).then((json) => {
|
|
|
store.delete(POSTING_CACHE_KEY);
|
|
|
dispatch(postFinished(true));
|
|
|
}).catch(error => {
|
...
|
...
|
@@ -178,41 +228,15 @@ export function startPosting(assets) { |
|
|
dispatch(postStart());
|
|
|
|
|
|
let storedState = getState().posting.toJS();
|
|
|
|
|
|
let assetsArray = storedState.assets;
|
|
|
let temp = [];
|
|
|
for (var i = 0; i < assetsArray.length; i++) {
|
|
|
let {
|
|
|
uri,
|
|
|
height,
|
|
|
width,
|
|
|
isStored,
|
|
|
url,
|
|
|
uti,
|
|
|
size,
|
|
|
finished,
|
|
|
name,
|
|
|
webURL,
|
|
|
}=assetsArray[i];
|
|
|
|
|
|
let newAsset = {
|
|
|
uri,
|
|
|
height,
|
|
|
width,
|
|
|
isStored,
|
|
|
url,
|
|
|
uti,
|
|
|
size,
|
|
|
finished,
|
|
|
name,
|
|
|
webURL,
|
|
|
}
|
|
|
temp.push(newAsset);
|
|
|
}
|
|
|
storedState.assets = temp;
|
|
|
storedState.boards = [];
|
|
|
|
|
|
storedState.postingBannerShow = true;
|
|
|
store.save(POSTING_CACHE_KEY,storedState).then(()=>{
|
|
|
console.log('00000000000000000000000000');
|
|
|
console.log(storedState);
|
|
|
store.get(POSTING_CACHE_KEY).then((data)=>{
|
|
|
console.log('11111111111111111111');
|
|
|
console.log(data);
|
|
|
})
|
|
|
if (assets.length) {
|
|
|
for (let i = 0; i < assets.length; i++) {
|
|
|
let asset = assets[i]
|
...
|
...
|
@@ -239,11 +263,9 @@ export function startPosting(assets) { |
|
|
contentData: posting.content,
|
|
|
}
|
|
|
return new PostingService().commitPost(param).then(json => {
|
|
|
console.log(json);
|
|
|
store.delete(POSTING_CACHE_KEY);
|
|
|
dispatch(postFinished(true));
|
|
|
}).catch(error => {
|
|
|
console.log('download error.....');
|
|
|
dispatch(postFinished(false));
|
|
|
});
|
|
|
});
|
...
|
...
|
|