~vesto/grooveboat

e425e6db09692c7587a8d2451dd7f4e08c21b287 — Steve Gattuso 5 years ago 1099bcf
more reliable room restoration
M src/js/pages/room-selector/data.js => src/js/pages/room-selector/data.js +5 -6
@@ 50,18 50,17 @@ function* joinBuoy({inviteCode, callback}) {

function* init() {
  yield put(BuoyActions.fetchBuoys());

  const {buoys} = yield take(BuoyActionTypes.FETCH_BUOYS_SUCCESS);
  if (process.env.DEFAULT_INVITE) {
    // Do we have a default buoy to go with?

  if (buoys.count() > 0) {
    yield put(BuoyActions.connect({buoy: buoys.get(0)}));
  } else if (buoys.count() === 0 && process.env.DEFAULT_INVITE) {
    yield call(joinBuoy, {inviteCode: process.env.DEFAULT_INVITE});
    return;
  }
  if (buoys.count() === 0 && !process.env.DEFAULT_INVITE) {
  } else if (buoys.count() === 0) {
    return;
  }

  yield put(BuoyActions.connect({buoy: buoys.get(0)}));
  const {type} = yield take([
    BuoyActionTypes.CONNECT_SUCCESS,
    BuoyActionTypes.CONNECT_FAILURE,

M src/js/pages/room-selector/index.js => src/js/pages/room-selector/index.js +1 -1
@@ 137,7 137,7 @@ const RoomSelectorPage = ({history}) => {
        {(!isConnecting && !connectedBuoy) && (
          <div className="selector--nobuoy">
            <div className="icon">🤔</div>
            <div className="text">can't establish connection with buoy. try contacting the admins?</div>
            <div className="text">can't establish connection with buoy. give it a sec and then refresh.</div>
          </div>
        )}
        {(connectedBuoy && screen === SCREEN_SELECT) && (

M src/js/services/buoys.js => src/js/services/buoys.js +1 -0
@@ 211,6 211,7 @@ function* join({inviteCode}) {
  }

  const buoy = {
    id: token.i,
    url: token.u,
    name: token.n,
    token: resp.token,

M src/js/services/rooms.js => src/js/services/rooms.js +1 -2
@@ 492,8 492,7 @@ function* restoreRoom({id}) {
    return;
  }

  const room = Immutable.fromJS(resp.room);
  yield put(Actions.joinRoomSuccess({room}));
  yield put(Actions.joinRoomSuccess({room: Immutable.fromJS(resp)}));
}

function* joinRoom({id}) {