"use strict";Object.defineProperty(exports, "__esModule", {value: true});

var _chunkLK72HAZ6js = require('./chunk-LK72HAZ6.js');


var _chunkDTIR4DVOjs = require('./chunk-DTIR4DVO.js');

// tmp-babel/messages/native/graphql/subscriptions/useRoomListSubscription.js
var _react = require('react');
var _useAppStateSubscription = require('@baseapp-frontend/utils/hooks/useAppStateSubscription');
var _exporouter = require('expo-router');
var _reactrelay = require('react-relay');
var useRoomListSubscription = function useRoomListSubscription2(_ref) {
  var connections = _ref.connections, profileId = _ref.profileId, onRemoval = _ref.onRemoval, environment = _ref.environment;
  var _useChatRoom = _chunkDTIR4DVOjs.useChatRoom_default.call(void 0, ), selectedRoom = _useChatRoom.id, resetChatRoom = _useChatRoom.resetChatRoom;
  var disposableRef = _react.useRef.call(void 0, null);
  var config = _react.useMemo.call(void 0, function() {
    return _chunkLK72HAZ6js.getRoomListSubscriptionConfig.call(void 0, profileId, connections, selectedRoom, resetChatRoom, onRemoval);
  }, [profileId, connections, onRemoval, selectedRoom, resetChatRoom]);
  var subscribe = _react.useCallback.call(void 0, function() {
    var _disposableRef$curren, _disposableRef$curren2;
    if (!profileId) return;
    (_disposableRef$curren = disposableRef.current) === null || _disposableRef$curren === void 0 || (_disposableRef$curren2 = _disposableRef$curren.dispose) === null || _disposableRef$curren2 === void 0 || _disposableRef$curren2.call(_disposableRef$curren);
    disposableRef.current = _reactrelay.requestSubscription.call(void 0, environment, config);
  }, [profileId, environment, config]);
  var unsubscribe = _react.useCallback.call(void 0, function() {
    var _disposableRef$curren3, _disposableRef$curren4;
    (_disposableRef$curren3 = disposableRef.current) === null || _disposableRef$curren3 === void 0 || (_disposableRef$curren4 = _disposableRef$curren3.dispose) === null || _disposableRef$curren4 === void 0 || _disposableRef$curren4.call(_disposableRef$curren3);
    disposableRef.current = null;
  }, []);
  _exporouter.useFocusEffect.call(void 0, _react.useCallback.call(void 0, function() {
    subscribe();
    return function() {
      unsubscribe();
    };
  }, [subscribe, unsubscribe]));
  _useAppStateSubscription.useAppStateSubscription.call(void 0, function() {
    subscribe();
  });
};



exports.useRoomListSubscription = useRoomListSubscription;
//# sourceMappingURL=chunk-MJCBPB5E.js.map