<commit_before>import firebase from 'firebase'

export const SET_ROOM     = 'SET_ROOM'
export const JOIN_ROOM    = 'JOIN_ROOM'
export const LEAVE_ROOM   = 'LEAVE_ROOM'
export const FETCH_ROOMS  = 'FETCH_ROOMS'
export const SET_SHIP     = 'SET_SHIP'
export const PUSH_ACTION  = 'PUSH_ACTION'

export function createRoom(room, callback=null) {
  return dispatch => {
    const ref = firebase.database().ref('rooms/' + room.id)

    ref.set(room, () => {
      if (callback) callback()
      dispatch({
        type: SET_ROOM,
        payload: { data: room }
      })
    })
  }
}

<commit_msg>delete room when user leave<commit_after>import firebase from 'firebase'

export const SET_ROOM     = 'SET_ROOM'
export const JOIN_ROOM    = 'JOIN_ROOM'
export const LEAVE_ROOM   = 'LEAVE_ROOM'
export const FETCH_ROOMS  = 'FETCH_ROOMS'
export const SET_SHIP     = 'SET_SHIP'
export const PUSH_ACTION  = 'PUSH_ACTION'

export function createRoom(room, callback=null) {
  return dispatch => {
    const ref = firebase.database().ref('rooms/' + room.id)

    ref.onDisconnect().remove()

    ref.set(room, () => {
      if (callback) callback()
      dispatch({
        type: SET_ROOM,
        payload: { data: room }
      })
    })
  }
}


{'fraction_non_alphanumeric': 0.11716842961757526, 'fraction_numerical': 0.0, 'mean_word_length': 3.1414141414141414, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6676335', 'n_tokens_mistral': 442, 'n_tokens_neox': 429, 'n_words': 101}