commit a115f551d05bf9b3b126c15b50ed2145825773c6
parent b3c0853a8b0eb00b1ac80c807b8dad81f9b3c682
Author: Matthew Horan <matt@matthoran.com>
Date: Sun, 6 Jan 2019 14:01:36 -0500
Fix ReferenceError in handling of hotlist message
Handling the hotlist action requires a call to getState in order to get
the currentBufferId.
The nonexistent state local variable was raising a ReferenceError, so no
buffers would show as having hot messages on connect.
Also fix a ReferenceError in the hotlists reducer, which was never
reached because of the above.
Diffstat:
2 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/src/lib/weechat/action_transformer.ts b/src/lib/weechat/action_transformer.ts
@@ -127,18 +127,22 @@ export const transformToReduxAction = (data: WeechatResponse<any>) => {
case "hotlist": {
const object = data.objects[0] as WeechatObject<WeechatHotlist[]>;
- return {
- type: "FETCH_HOTLISTS",
- payload: reduceToObjectByKey(
- object.content,
- hotlist => hotlist.buffer,
- h => {
- const [unknown, message, privmsg, highlight] = h.count;
- const sum = message + privmsg + highlight;
- return { ...h, message, privmsg, highlight, sum };
- }
- ),
- currentBufferId: state.app.currentBufferId
+ return (dispatch, getState) => {
+ const state: StoreState = getState();
+
+ dispatch({
+ type: "FETCH_HOTLISTS",
+ payload: reduceToObjectByKey(
+ object.content,
+ hotlist => hotlist.buffer,
+ h => {
+ const [unknown, message, privmsg, highlight] = h.count;
+ const sum = message + privmsg + highlight;
+ return { ...h, message, privmsg, highlight, sum };
+ }
+ ),
+ currentBufferId: state.app.currentBufferId
+ });
};
}
case "nicklist": {
diff --git a/src/store/hotlists.ts b/src/store/hotlists.ts
@@ -9,7 +9,7 @@ export default (state: HotListState = initialState, action): HotListState => {
switch (action.type) {
case "FETCH_HOTLISTS":
if (action.currentBufferId) {
- return omit(action.payload, currentBufferId);
+ return omit(action.payload, action.currentBufferId);
}
return action.payload;