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

commit e33492754cd3f6c63672d78ba2e79c2c12baa1e9
parent 3e13e736dadcb1bbe19db2e609bc11739c0a892e
Author: Matthew Horan <matt@matthoran.com>
Date:   Sun,  1 Nov 2020 13:03:23 -0500

Remove lodash as dependency

Diffstat:
Mpackage.json | 2--
Msrc/store/buffers.ts | 5++---
Msrc/store/hotlists.ts | 7++++---
Msrc/store/lines.ts | 6++----
Msrc/store/nicklists.ts | 6++----
Msrc/usecase/App.tsx | 5++---
Mtsconfig.json | 3+--
Myarn.lock | 7+------
8 files changed, 14 insertions(+), 27 deletions(-)

diff --git a/package.json b/package.json @@ -14,7 +14,6 @@ "expo": "^39.0.0", "expo-notifications": "~0.7.2", "js-sha256": "^0.9.0", - "lodash": "^4.17.5", "react": "16.13.1", "react-native": "https://github.com/expo/react-native/archive/sdk-39.0.0.tar.gz", "react-native-drawer-layout-polyfill": "^2.0.0", @@ -28,7 +27,6 @@ "@babel/core": "^7.2.2", "@testing-library/react-native": "^7.0.2", "@types/jest": "^26.0.14", - "@types/lodash": "^4.14.106", "@types/react": "~16.9.35", "@types/react-native": "~0.63.2", "@types/react-redux": "^7.1.9", diff --git a/src/store/buffers.ts b/src/store/buffers.ts @@ -1,5 +1,3 @@ -import { omit } from "lodash"; - export type BufferState = { [key: string]: WeechatBuffer }; const initialState: BufferState = {}; @@ -10,7 +8,8 @@ export default (state: BufferState = initialState, action): BufferState => { return action.payload; } case "BUFFER_CLOSED": { - return omit(state, action.bufferId); + return Object.fromEntries(Object.entries(state) + .filter(([bufferId]) => bufferId !== action.bufferId)); } case "BUFFER_OPENED": { return { diff --git a/src/store/hotlists.ts b/src/store/hotlists.ts @@ -1,4 +1,3 @@ -import { omit } from "lodash"; import { getHotlistForBufferId } from "./selectors"; export type HotListState = { [key: string]: Hotlist }; @@ -9,12 +8,14 @@ export default (state: HotListState = initialState, action): HotListState => { switch (action.type) { case "FETCH_HOTLISTS": if (action.currentBufferId) { - return omit(action.payload, action.currentBufferId); + return Object.fromEntries(Object.entries(<HotListState> action.payload) + .filter(([bufferId]) => bufferId !== action.currentBufferId)); } return action.payload; case "CHANGE_CURRENT_BUFFER": - return omit(state, action.bufferId); + return Object.fromEntries(Object.entries(state) + .filter(([bufferId]) => bufferId !== action.bufferId)); case "BUFFER_LINE_ADDED": { if (action.bufferId === action.currentBufferId) { return state; diff --git a/src/store/lines.ts b/src/store/lines.ts @@ -1,5 +1,3 @@ -import { omit } from "lodash"; - export type LineState = { [key: string]: WeechatLine[] }; const initialState: LineState = {}; @@ -12,8 +10,8 @@ export default (state: LineState = initialState, action): LineState => { [action.bufferId]: action.payload }; case "BUFFER_CLOSED": { - const newState = omit(state, action.bufferId); - return newState; + return Object.fromEntries(Object.entries(state) + .filter(([bufferId]) => bufferId !== action.bufferId)); } case "BUFFER_LINE_ADDED": return { diff --git a/src/store/nicklists.ts b/src/store/nicklists.ts @@ -1,5 +1,3 @@ -import { omit } from "lodash"; - export type NicklistState = { [key: string]: WeechatNicklist[] }; const initialState: NicklistState = {}; @@ -26,8 +24,8 @@ export default (state: NicklistState = initialState, action): NicklistState => { }; } case "BUFFER_CLOSED": { - const newState = omit(state, action.bufferId); - return newState; + return Object.fromEntries(Object.entries(state) + .filter(([bufferId]) => bufferId !== action.bufferId)); } default: return state; diff --git a/src/usecase/App.tsx b/src/usecase/App.tsx @@ -11,7 +11,6 @@ import { Platform } from 'react-native'; import { connect, ConnectedProps } from 'react-redux'; -import * as _ from 'lodash'; import DrawerLayout from 'react-native-drawer-layout-polyfill'; @@ -25,7 +24,7 @@ const connector = connect((state: StoreState) => { const currentBuffer = (currentBufferId && state.buffers[currentBufferId]) || null; - const numHighlights = _.values(state.hotlists).reduce( + const numHighlights = Object.values(state.hotlists).reduce( (sum, hlist) => sum + hlist.highlight, 0 ); @@ -149,7 +148,7 @@ class App extends React.Component<Props, State> { const sidebar = () => ( <BufferList - buffers={_.orderBy(_.values(buffers), ['number'])} + buffers={Object.values(buffers).sort((a, b) => a.number - b.number)} currentBufferId={currentBufferId} onSelectBuffer={this.changeCurrentBuffer} /> diff --git a/tsconfig.json b/tsconfig.json @@ -4,8 +4,7 @@ "allowSyntheticDefaultImports": true, "esModuleInterop": true, "isolatedModules": true, - "jsx": "react", - "lib": ["es6"], + "jsx": "react-native", "moduleResolution": "node", "noEmit": true, "strict": true, diff --git a/yarn.lock b/yarn.lock @@ -2327,11 +2327,6 @@ resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.6.tgz#f4c7ec43e81b319a9815115031709f26987891f0" integrity sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw== -"@types/lodash@^4.14.106": - version "4.14.149" - resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.149.tgz#1342d63d948c6062838fbf961012f74d4e638440" - integrity sha512-ijGqzZt/b7BfzcK9vTrS6MFljQRPn5BFWOx8oE0GYxribu6uV+aA9zZuXI1zc/etK9E8nrgdoF2+LgUw7+9tJQ== - "@types/node@*": version "14.6.4" resolved "https://registry.yarnpkg.com/@types/node/-/node-14.6.4.tgz#a145cc0bb14ef9c4777361b7bbafa5cf8e3acb5a" @@ -6781,7 +6776,7 @@ lodash.throttle@^4.1.1: resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4" integrity sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ= -lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0, lodash@^4.5.0, lodash@^4.6.0: +lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4, lodash@^4.3.0, lodash@^4.5.0, lodash@^4.6.0: version "4.17.15" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==