mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-21 04:11:50 +03:00
added author with draftId for unique Map reference
This commit is contained in:
parent
9ba51bef3d
commit
d034be445f
@ -46,10 +46,10 @@ export const QuickReplyModalContent = ({
|
||||
const [quickCommentDraft, setQuickCommentDraft] = useState<Draft>(null);
|
||||
|
||||
const headerText =
|
||||
selectedPost && (selectedPost.summary || postBodySummary(selectedPost, 150, Platform.OS));
|
||||
selectedPost && (selectedPost.summary || postBodySummary(selectedPost, 150, Platform.OS as any));
|
||||
const parentAuthor = selectedPost ? selectedPost.author : '';
|
||||
const parentPermlink = selectedPost ? selectedPost.permlink : '';
|
||||
const draftId = `${parentAuthor}/${parentPermlink}`;
|
||||
const draftId = `${currentAccount.name}/${parentAuthor}/${parentPermlink}`; //different draftId for each user acount
|
||||
|
||||
useEffect(() => {
|
||||
handleCloseRef.current = handleSheetClose;
|
||||
@ -57,7 +57,7 @@ export const QuickReplyModalContent = ({
|
||||
|
||||
// load quick comment value from cache
|
||||
useEffect(() => {
|
||||
if (drafts.has(draftId)) {
|
||||
if (drafts.has(draftId) && currentAccount.name === drafts.get(draftId).author) {
|
||||
const quickComment: Draft = drafts.get(draftId);
|
||||
setCommentValue(quickComment.body);
|
||||
setQuickCommentDraft(quickComment);
|
||||
@ -78,6 +78,7 @@ export const QuickReplyModalContent = ({
|
||||
const updatedStamp = date.toISOString().substring(0, 19);
|
||||
|
||||
const quickCommentDraftData: Draft = {
|
||||
author: currentAccount.name,
|
||||
parent_permlink: parentPermlink,
|
||||
body: commentValue,
|
||||
created: quickCommentDraft ? quickCommentDraft.created : updatedStamp,
|
||||
|
@ -74,10 +74,10 @@ import { Comment, Draft, Vote } from '../reducers/cacheReducer';
|
||||
type: DELETE_COMMENT_CACHE_ENTRY
|
||||
})
|
||||
|
||||
export const updateDraftCache = (id:string, quickComment:Draft) => ({
|
||||
export const updateDraftCache = (id:string, draft:Draft) => ({
|
||||
payload:{
|
||||
id,
|
||||
quickComment
|
||||
draft
|
||||
},
|
||||
type: UPDATE_DRAFT_CACHE
|
||||
})
|
||||
|
@ -27,6 +27,7 @@ export interface Comment {
|
||||
}
|
||||
|
||||
export interface Draft {
|
||||
author: string,
|
||||
parent_permlink:string,
|
||||
body?:string,
|
||||
created?:string,
|
||||
@ -93,7 +94,7 @@ const initialState:State = {
|
||||
if(!state.drafts){
|
||||
state.drafts = new Map<string, Draft>();
|
||||
}
|
||||
state.drafts.set(payload.id, payload.quickComment);
|
||||
state.drafts.set(payload.id, payload.draft);
|
||||
return {
|
||||
...state, //spread operator in requried here, otherwise persist do not register change
|
||||
lastUpdate: {
|
||||
|
Loading…
Reference in New Issue
Block a user