Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 6934 Rev 6935
Línea 97... Línea 97...
97
    width: 1rem;
97
    width: 1rem;
98
    height: 1rem;
98
    height: 1rem;
99
  }
99
  }
Línea 100... Línea 100...
100
 
100
 
101
  ${(props) => {
-
 
102
    console.log('Render')
101
  ${(props) => {
103
    if (props.send) {
102
    if (props.send) {
104
      return css`
103
      return css`
105
        align-self: flex-end;
104
        align-self: flex-end;
106
        background-color: var(--chat-send);
105
        background-color: var(--chat-send);
Línea 116... Línea 115...
116
    `
115
    `
117
  }}
116
  }}
118
`
117
`
Línea 119... Línea 118...
119
 
118
 
120
function messageAreEqual(oldProps, newProps) {
-
 
121
  const messageDifference = oldProps.messages?.filter(
-
 
122
    (message, index) => newProps.messages[index].id !== message.id && message
-
 
123
  )
-
 
124
 
-
 
125
  console.log(messageDifference)
-
 
126
 
119
function messageAreEqual(oldProps, newProps) {
127
  return Boolean(messageDifference.length)
120
  return oldProps.message.id === newProps.message.id
Línea 128... Línea 121...
128
}
121
}
129
 
122
 
130
const Chat = ({ children }) => {
123
const Chat = ({ children }) => {
Línea 153... Línea 146...
153
      <StyledTitle>{children}</StyledTitle>
146
      <StyledTitle>{children}</StyledTitle>
154
    </a>
147
    </a>
155
  )
148
  )
156
}
149
}
Línea 157... Línea 150...
157
 
150
 
158
const MemoList = memo(function List({
151
const List = ({
159
  messages = [],
152
  messages = [],
160
  pages,
153
  pages,
161
  currentPage,
154
  currentPage,
162
  onPagination,
155
  onPagination,
163
  scrollRef,
156
  scrollRef,
164
  loading,
157
  loading,
165
}) {
158
}) => {
Línea 166... Línea 159...
166
  const loadMoreEl = useRef(null)
159
  const loadMoreEl = useRef(null)
167
 
160
 
Línea 178... Línea 171...
178
  }, [messages])
171
  }, [messages])
Línea 179... Línea 172...
179
 
172
 
180
  return (
173
  return (
181
    <StyledMessageList ref={scrollRef}>
174
    <StyledMessageList ref={scrollRef}>
182
      {messages.map((message) => (
175
      {messages.map((message) => (
183
        <MemoList.Message message={message} key={message.id} />
176
        <List.Message message={message} key={message.id} />
184
      ))}
177
      ))}
185
      {pages > currentPage && !loading && <p ref={loadMoreEl}>Cargando...</p>}
178
      {pages > currentPage && !loading && <p ref={loadMoreEl}>Cargando...</p>}
186
    </StyledMessageList>
179
    </StyledMessageList>
187
  )
180
  )
188
},
-
 
Línea -... Línea 181...
-
 
181
}
189
messageAreEqual)
182
 
190
 
183
// eslint-disable-next-line react/display-name
191
const Message = ({ message }) => {
184
const Message = memo(({ message }) => {
192
  const senderName = (message) => {
185
  const senderName = (message) => {
Línea -... Línea 186...
-
 
186
    if (message.type === 'group' && !message.u === 1) return message.user_name
-
 
187
  }
193
    if (message.type === 'group' && !message.u === 1) return message.user_name
188
 
194
  }
189
  console.log('Render')
195
 
190
 
196
  const messagesContent = {
191
  const messagesContent = {
197
    // eslint-disable-next-line no-undef
192
    // eslint-disable-next-line no-undef
Línea 222... Línea 217...
222
          {message.time}
217
          {message.time}
223
        </label>
218
        </label>
224
      </StyledMessage>
219
      </StyledMessage>
225
    </>
220
    </>
226
  )
221
  )
227
}
222
}, messageAreEqual)
Línea 228... Línea 223...
228
 
223
 
229
const SubmitForm = ({ sendUrl, uploadUrl, onSubmit: onComplete }) => {
224
const SubmitForm = ({ sendUrl, uploadUrl, onSubmit: onComplete }) => {
230
  const [showEmojione, setShowEmojione] = useState(false)
225
  const [showEmojione, setShowEmojione] = useState(false)
231
  const [isShowFileModal, setIsShowFileModal] = useState(false)
226
  const [isShowFileModal, setIsShowFileModal] = useState(false)