Skip to content

Commit

Permalink
fix: [useMessages] support msg.hasTime
Browse files Browse the repository at this point in the history
  • Loading branch information
akai committed Apr 29, 2021
1 parent 730b626 commit bd01305
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/hooks/useMessages.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-underscore-dangle */
import { useState, useMemo, useRef, useCallback } from 'react';
import { getRandomString } from '../utils';
import { MessageProps, MessageId } from '../components/Message';
Expand All @@ -12,7 +13,7 @@ let lastTs = 0;

const makeMsg = (msg: MessageWithoutId, id?: MessageId) => {
const ts = msg.createdAt || Date.now();
const hasTime = ts - lastTs > TIME_GAP;
const hasTime = msg.hasTime || ts - lastTs > TIME_GAP;

if (hasTime) {
lastTs = ts;
Expand Down

0 comments on commit bd01305

Please sign in to comment.