This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Sling.UserSocket do | |
| use Phoenix.Socket | |
| channel "rooms:*", Sling.RoomChannel | |
| transport :websocket, Phoenix.Transports.WebSocket | |
| def connect(%{"token" => token}, socket) do | |
| case Guardian.decode_and_verify(token) do | |
| {:ok, claims} -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Sling.Message do | |
| use Sling.Web, :model | |
| schema "messages" do | |
| field :text, :string | |
| belongs_to :room, Sling.Room | |
| belongs_to :user, Sling.User | |
| timestamps() | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Sling.Repo.Migrations.CreateMessage do | |
| use Ecto.Migration | |
| def change do | |
| create table(:messages) do | |
| add :text, :string, null: false | |
| add :room_id, references(:rooms, on_delete: :nothing), null: false | |
| add :user_id, references(:users, on_delete: :nothing), null: false | |
| timestamps() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // @flow | |
| import React, { Component } from 'react'; | |
| import { Field, reduxForm } from 'redux-form'; | |
| type Props = { | |
| handleSubmit: () => void, | |
| onSubmit: () => void, | |
| submitting: boolean, | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| type Props = { | |
| room: { | |
| id: number, | |
| name: string, | |
| }, | |
| currentUserRoomIds: Array, | |
| onRoomJoin: () => void, | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // @flow | |
| import React, { Component, PropTypes } from 'react'; | |
| import { connect } from 'react-redux'; | |
| import { css, StyleSheet } from 'aphrodite'; | |
| import { fetchRooms, createRoom, joinRoom } from '../../actions/rooms'; | |
| import NewRoomForm from '../../components/NewRoomForm'; | |
| import Navbar from '../../components/Navbar'; | |
| import RoomListItem from '../../components/RoomListItem'; | |
| const styles = StyleSheet.create({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // @flow | |
| import React from 'react'; | |
| import { Link } from 'react-router'; | |
| import { css, StyleSheet } from 'aphrodite'; | |
| const styles = StyleSheet.create({ | |
| sidebar: { | |
| display: 'flex', | |
| flexDirection: 'column', | |
| background: 'rgb(38,28,37)', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // @flow | |
| import React from 'react'; | |
| const Room = props => | |
| <div>Room {props.params.id}</div>; | |
| export default Room; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // @flow | |
| import React, { Component } from 'react'; | |
| import { BrowserRouter, Miss } from 'react-router'; | |
| import { connect } from 'react-redux'; | |
| import { authenticate, unauthenticate, logout } from '../../actions/session'; | |
| import Home from '../Home'; | |
| import NotFound from '../../components/NotFound'; | |
| import Login from '../Login'; | |
| import Signup from '../Signup'; | |
| import MatchAuthenticated from '../../components/MatchAuthenticated'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { combineReducers } from 'redux'; | |
| import { reducer as form } from 'redux-form'; | |
| import session from './session'; | |
| import rooms from './rooms'; // new line | |
| const appReducer = combineReducers({ | |
| form, | |
| session, | |
| rooms, // new line | |
| }); |