"use strict";

import { setLastViewedTimestamp } from '../roomStore/roomsSlice';
export const updatedChatLastTimestamps = (roomTimestampObject, dispatch) => {
  if (!roomTimestampObject) {
    return;
  }
  if (roomTimestampObject && Object.keys(roomTimestampObject).length > 0) {
    const roomTimestampArray = Object.entries(roomTimestampObject).map(([jid, timestamp]) => ({
      jid,
      timestamp
    }));
    console.log('getting roomTimestampArray', roomTimestampArray);
    roomTimestampArray.forEach(({
      jid,
      timestamp
    }) => {
      if (jid) {
        dispatch(setLastViewedTimestamp({
          chatJID: jid,
          timestamp: Number(timestamp || 0)
        }));
      }
    });
  }
};
//# sourceMappingURL=updatedChatLastTimestamps.js.map