"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.updatedChatLastTimestamps = void 0;
var _roomsSlice = require("../roomStore/roomsSlice");
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((0, _roomsSlice.setLastViewedTimestamp)({
          chatJID: jid,
          timestamp: Number(timestamp || 0)
        }));
      }
    });
  }
};
exports.updatedChatLastTimestamps = updatedChatLastTimestamps;
//# sourceMappingURL=updatedChatLastTimestamps.js.map