import { Server , ServerId , Channel , ChannelId , Message } from "./discord" ; export enum ActionType { CHANGE_CHANNEL , ADD_SERVER , ADD_CHANNEL , LOG_LINE , CORK , UNCORK , CHAT_MESSAGE , FOCUS_CHANNEL_LIST , TOGGLE_SERVER_COLLAPSE , RESIZE_SCREEN , FINISH_LOG_LOADING , START_LOGIN , LOGGED_IN , SCROLL_UP } export interface Action { type : ActionType ; payload : any ; error ? : boolean ; } export function changeChannel ( id ) { return { type : ActionType . CHANGE_CHANNEL , payload : { channelId : id } } ; } export function addServer ( server ) { return { type : ActionType . ADD_SERVER , payload : { server : server } } ; } export function addChannel ( channel ) { return { type : ActionType . ADD_CHANNEL , payload : { channel : channel } } ; } export function logLine ( line ) { return { type : ActionType . LOG_LINE , payload : { log : line } } ; } export function cork ( ) { return { type : ActionType . CORK , payload : null } ; } export function uncork ( ) { return { type : ActionType . UNCORK , payload : null } ; } export function chatMessage ( message ) { return { type : ActionType . CHAT_MESSAGE , payload : { message : message } } ; } export function focusChannelList ( ) { return { type : ActionType . FOCUS_CHANNEL_LIST , payload : null } ; } export function toggleServerCollapse ( id ) { return { type : ActionType . TOGGLE_SERVER_COLLAPSE , payload : { serverId : id } } ; } export function resizeScreen ( width , height ) { return { type : ActionType . RESIZE_SCREEN , payload : { width : width , height : height } } ; } export function finishLogLoading ( ) { return { type : ActionType . FINISH_LOG_LOADING , payload : null } ; } export function startLogin ( ) { return { type : ActionType . START_LOGIN , payload : null } ; } export function loggedIn ( ) { return { type : ActionType . LOGGED_IN , payload : null } ; } export function loginError ( error ) { return { type : ActionType . LOGGED_IN , payload : error , error : true } ; } export function scrollUp ( lines ) { return { type : ActionType . SCROLL_UP , payload : { lines : lines } } ; }