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

lines.ts (645B)


      1 export type LineState = { [key: string]: WeechatLine[] };
      2 
      3 const initialState: LineState = {};
      4 
      5 export default (state: LineState = initialState, action): LineState => {
      6   switch (action.type) {
      7     case "FETCH_LINES":
      8       return {
      9         ...state,
     10         [action.bufferId]: action.payload
     11       };
     12     case "BUFFER_CLOSED": {
     13       return Object.fromEntries(Object.entries(state)
     14         .filter(([bufferId]) => bufferId !== action.bufferId));
     15     }
     16     case "BUFFER_LINE_ADDED":
     17       return {
     18         ...state,
     19         [action.bufferId]: [action.payload, ...(state[action.bufferId] || [])]
     20       };
     21     default:
     22       return state;
     23   }
     24 };