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 [quickCommentDraft, setQuickCommentDraft] = useState<Draft>(null);
|
||||||
|
|
||||||
const headerText =
|
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 parentAuthor = selectedPost ? selectedPost.author : '';
|
||||||
const parentPermlink = selectedPost ? selectedPost.permlink : '';
|
const parentPermlink = selectedPost ? selectedPost.permlink : '';
|
||||||
const draftId = `${parentAuthor}/${parentPermlink}`;
|
const draftId = `${currentAccount.name}/${parentAuthor}/${parentPermlink}`; //different draftId for each user acount
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
handleCloseRef.current = handleSheetClose;
|
handleCloseRef.current = handleSheetClose;
|
||||||
@ -57,7 +57,7 @@ export const QuickReplyModalContent = ({
|
|||||||
|
|
||||||
// load quick comment value from cache
|
// load quick comment value from cache
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (drafts.has(draftId)) {
|
if (drafts.has(draftId) && currentAccount.name === drafts.get(draftId).author) {
|
||||||
const quickComment: Draft = drafts.get(draftId);
|
const quickComment: Draft = drafts.get(draftId);
|
||||||
setCommentValue(quickComment.body);
|
setCommentValue(quickComment.body);
|
||||||
setQuickCommentDraft(quickComment);
|
setQuickCommentDraft(quickComment);
|
||||||
@ -78,6 +78,7 @@ export const QuickReplyModalContent = ({
|
|||||||
const updatedStamp = date.toISOString().substring(0, 19);
|
const updatedStamp = date.toISOString().substring(0, 19);
|
||||||
|
|
||||||
const quickCommentDraftData: Draft = {
|
const quickCommentDraftData: Draft = {
|
||||||
|
author: currentAccount.name,
|
||||||
parent_permlink: parentPermlink,
|
parent_permlink: parentPermlink,
|
||||||
body: commentValue,
|
body: commentValue,
|
||||||
created: quickCommentDraft ? quickCommentDraft.created : updatedStamp,
|
created: quickCommentDraft ? quickCommentDraft.created : updatedStamp,
|
||||||
|
@ -74,10 +74,10 @@ import { Comment, Draft, Vote } from '../reducers/cacheReducer';
|
|||||||
type: DELETE_COMMENT_CACHE_ENTRY
|
type: DELETE_COMMENT_CACHE_ENTRY
|
||||||
})
|
})
|
||||||
|
|
||||||
export const updateDraftCache = (id:string, quickComment:Draft) => ({
|
export const updateDraftCache = (id:string, draft:Draft) => ({
|
||||||
payload:{
|
payload:{
|
||||||
id,
|
id,
|
||||||
quickComment
|
draft
|
||||||
},
|
},
|
||||||
type: UPDATE_DRAFT_CACHE
|
type: UPDATE_DRAFT_CACHE
|
||||||
})
|
})
|
||||||
|
@ -27,6 +27,7 @@ export interface Comment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Draft {
|
export interface Draft {
|
||||||
|
author: string,
|
||||||
parent_permlink:string,
|
parent_permlink:string,
|
||||||
body?:string,
|
body?:string,
|
||||||
created?:string,
|
created?:string,
|
||||||
@ -93,7 +94,7 @@ const initialState:State = {
|
|||||||
if(!state.drafts){
|
if(!state.drafts){
|
||||||
state.drafts = new Map<string, Draft>();
|
state.drafts = new Map<string, Draft>();
|
||||||
}
|
}
|
||||||
state.drafts.set(payload.id, payload.quickComment);
|
state.drafts.set(payload.id, payload.draft);
|
||||||
return {
|
return {
|
||||||
...state, //spread operator in requried here, otherwise persist do not register change
|
...state, //spread operator in requried here, otherwise persist do not register change
|
||||||
lastUpdate: {
|
lastUpdate: {
|
||||||
|
Loading…
Reference in New Issue
Block a user