mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-21 04:11:50 +03:00
delete quick comment cache after comment is done
This commit is contained in:
parent
ba5f3f1e33
commit
4e71d2901b
@ -8,7 +8,11 @@ import { useSelector, useDispatch } from 'react-redux';
|
|||||||
import { delay, generateReplyPermlink } from '../../utils/editor';
|
import { delay, generateReplyPermlink } from '../../utils/editor';
|
||||||
import { postComment } from '../../providers/hive/dhive';
|
import { postComment } from '../../providers/hive/dhive';
|
||||||
import { toastNotification } from '../../redux/actions/uiAction';
|
import { toastNotification } from '../../redux/actions/uiAction';
|
||||||
import { updateCommentCache, updateQuickCommentCache } from '../../redux/actions/cacheActions';
|
import {
|
||||||
|
deleteQuickCommentCacheEntry,
|
||||||
|
updateCommentCache,
|
||||||
|
updateQuickCommentCache,
|
||||||
|
} from '../../redux/actions/cacheActions';
|
||||||
import { default as ROUTES } from '../../constants/routeNames';
|
import { default as ROUTES } from '../../constants/routeNames';
|
||||||
import get from 'lodash/get';
|
import get from 'lodash/get';
|
||||||
import { navigate } from '../../navigation/service';
|
import { navigate } from '../../navigation/service';
|
||||||
@ -62,13 +66,14 @@ export const QuickReplyModalContent = ({
|
|||||||
// handlers
|
// handlers
|
||||||
|
|
||||||
const handleSheetClose = () => {
|
const handleSheetClose = () => {
|
||||||
console.log('sheet closed!');
|
_addQuickCommentIntoCache();
|
||||||
|
};
|
||||||
|
|
||||||
|
// add quick comment value into cache
|
||||||
|
const _addQuickCommentIntoCache = () => {
|
||||||
if (!commentValue) {
|
if (!commentValue) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log('commentValue : ', commentValue);
|
|
||||||
|
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
const updatedStamp = date.toISOString().substring(0, 19);
|
const updatedStamp = date.toISOString().substring(0, 19);
|
||||||
|
|
||||||
@ -83,7 +88,6 @@ export const QuickReplyModalContent = ({
|
|||||||
//add quick comment cache entry
|
//add quick comment cache entry
|
||||||
dispatch(updateQuickCommentCache(`${parentAuthor}/${parentPermlink}`, quickCommentCache));
|
dispatch(updateQuickCommentCache(`${parentAuthor}/${parentPermlink}`, quickCommentCache));
|
||||||
};
|
};
|
||||||
|
|
||||||
// handle close press
|
// handle close press
|
||||||
const _handleClosePress = () => {
|
const _handleClosePress = () => {
|
||||||
sheetModalRef.current?.setModalVisible(false);
|
sheetModalRef.current?.setModalVisible(false);
|
||||||
@ -167,7 +171,10 @@ export const QuickReplyModalContent = ({
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
// delete quick cache if it exist
|
||||||
|
if (quickComments.has(path)) {
|
||||||
|
dispatch(deleteQuickCommentCacheEntry(path));
|
||||||
|
}
|
||||||
clearTimeout(stateTimer);
|
clearTimeout(stateTimer);
|
||||||
}, 3000);
|
}, 3000);
|
||||||
})
|
})
|
||||||
@ -181,6 +188,7 @@ export const QuickReplyModalContent = ({
|
|||||||
);
|
);
|
||||||
stateTimer = setTimeout(() => {
|
stateTimer = setTimeout(() => {
|
||||||
setIsSending(false);
|
setIsSending(false);
|
||||||
|
_addQuickCommentIntoCache(); //add comment value into cache if there is error while posting comment
|
||||||
clearTimeout(stateTimer);
|
clearTimeout(stateTimer);
|
||||||
}, 500);
|
}, 500);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user