Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 56626a63

Přidáno uživatelem Fantič před více než 1 rok

#re 10797 NotesListView set replying optimize

Zobrazit rozdíly:

src/components/notes/NotesListView.tsx
2 2
import { Note } from "../../types/note";
3 3
import NoteView from "./NoteView";
4 4
import { MessageIcon } from "../general/Icons";
5
import React, { useState } from "react";
5
import React, { useCallback, useState } from "react";
6 6
import { updateNote, deleteNote } from "../../stores/actions/notesThunks";
7 7
import { ConfirmDialog } from "../general/Dialogs";
8 8
import { AppDispatch } from "../../stores/store";
......
28 28
        onSubmit?: () => void;
29 29
    } | null>(null);
30 30

  
31
    const handleReply = (messageId: string, userName: string) => {
32
        setReplyingTo({ messageId, userName })
33
    }
34

  
35
    const handleEdit = (note: Note) => {
36
        if (!props.requestPending)
31
    const handleReply = useCallback((messageId: string, userName: string) => {
32
        setReplyingTo({ messageId, userName });
33
    }, [setReplyingTo]);
34
    
35
    const handleEdit = useCallback((note: Note) => {
36
        if (!props.requestPending) {
37 37
            dispatch(updateNote(note));
38
    }
39

  
40
    const handleDelete = (messageId: string) => {
41
        if (!props.requestPending)
42
            dispatch(deleteNote({ noteId: messageId }))
43
    }
38
        }
39
    }, [dispatch, props.requestPending]);
40
    
41
    const handleDelete = useCallback((messageId: string) => {
42
        if (!props.requestPending) {
43
            dispatch(deleteNote({ noteId: messageId }));
44
        }
45
    }, [dispatch, props.requestPending]);
44 46

  
45 47
    return (
46 48
        <VStack>

Také k dispozici: Unified diff