weechatRN

Weechat relay client for iOS using websockets https://github.com/mhoran/weechatRN
git clone http://git.hanabi.in/repos/weechatRN.git
Log | Files | Refs | README | LICENSE

nicklists.ts (872B)


      1 export type NicklistState = { [key: string]: WeechatNicklist[] };
      2 
      3 const initialState: NicklistState = {};
      4 
      5 export default (state: NicklistState = initialState, action): NicklistState => {
      6   switch (action.type) {
      7     case "FETCH_NICKLIST":
      8       return {
      9         ...state,
     10         [action.bufferId]: action.payload
     11       };
     12     case "NICK_ADDED": {
     13       return {
     14         ...state,
     15         [action.bufferId]: [...(state[action.bufferId] || []), action.payload]
     16       };
     17     }
     18     case "NICK_REMOVED": {
     19       return {
     20         ...state,
     21         [action.bufferId]: (state[action.bufferId] || []).filter(
     22           nick => nick.name !== action.payload.name
     23         )
     24       };
     25     }
     26     case "BUFFER_CLOSED": {
     27       return Object.fromEntries(Object.entries(state)
     28         .filter(([bufferId]) => bufferId !== action.bufferId));
     29     }
     30     default:
     31       return state;
     32   }
     33 };