Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 892 | Rev 894 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 892 Rev 893
Línea 7... Línea 7...
7
export default props => {
7
export default props => {
8
    const defaultPages = { current: 1, last: 1 }
8
    const defaultPages = { current: 1, last: 1 }
9
    const [conversations, setConversations] = useState([])
9
    const [conversations, setConversations] = useState([])
10
    const [showConversations, setShowConversations] = useState(false)
10
    const [showConversations, setShowConversations] = useState(false)
11
    const [selectedConversation, setSelectedConversation] = useState(null)
11
    const [selectedConversation, setSelectedConversation] = useState(null)
12
    const [page, setPage] = useState({ current: 1, last: 1 })
12
    const [page, setPage] = useState(defaultPages)
13
    const [messages, setMessages] = useState([])
13
    const [messages, setMessages] = useState([])
14
    const [isGettingMessages, setIsGettingMessages] = useState(false)
14
    const [isGettingMessages, setIsGettingMessages] = useState(false)
15
    const [visible, setVisible] = useState(false)
15
    const [visible, setVisible] = useState(false)
16
    const [searchActive, setSearchActive] = useState(false)
16
    const [searchActive, setSearchActive] = useState(false)
17
    const [inmailPersons, setInmailPersons] = useState([])
17
    const [inmailPersons, setInmailPersons] = useState([])
Línea 50... Línea 50...
50
            if (justPaginate) {
50
            if (justPaginate) {
51
                setMessages([...messages, ...res.data.data])
51
                setMessages([...messages, ...res.data.data])
52
            } else {
52
            } else {
53
                setMessages(res.data.data)
53
                setMessages(res.data.data)
54
            }
54
            }
-
 
55
        }
55
        } catch (error) {
56
        catch (error) {
56
            console.log('>>: error > ', error)
57
            console.log('>>: error > ', error)
57
        } finally {
58
        }
58
            if (isGettingMessages) {
59
        finally {
59
                setIsGettingMessages(false)
60
            setIsGettingMessages(false)
60
            }
-
 
61
        }
61
        }
62
    }
62
    }
Línea 63... Línea 63...
63
 
63
 
64
    const handleChangeConversation = async conversation => {
64
    const handleChangeConversation = async conversation => {
Línea 85... Línea 85...
85
            }
85
            }
86
        }
86
        }
87
    }
87
    }
Línea 88... Línea 88...
88
 
88
 
89
    const getMoreMessages = () => {
89
    const getMoreMessages = () => {
90
        console.log(page.current);
90
        if (!isGettingMessages) {
91
        console.log(page.last);
91
            setIsGettingMessages(true)
92
        console.log(page.last > page.current);
92
        }
93
        if (page.last > page.current) {
93
        if (page.last > page.current) {
94
            let { current } = page
-
 
95
            current += 1
-
 
96
            if (!isGettingMessages) {
-
 
97
                setIsGettingMessages(true)
-
 
98
                setPage({
-
 
99
                    ...page,
-
 
100
                    current
-
 
101
                })
94
            setPage({ ...page, current: page.current + 1 })
102
                getMessages(selectedConversation, current, true)
-
 
103
            }
95
            getMessages(selectedConversation, current, true)
104
        }
96
        }
Línea 105... Línea 97...
105
    }
97
    }
106
 
98