Convert withModal to useModal

This commit is contained in:
Ken-Håvard Lieng 2020-05-03 09:05:16 +02:00
parent 9cf42df1ea
commit 530e08b9ee
32 changed files with 791 additions and 737 deletions

View file

@ -9,7 +9,7 @@ export const getWindowWidth = state => state.app.windowWidth;
export const getConnectDefaults = state => state.app.connectDefaults;
const initialState = {
connected: true,
connected: false,
wrapWidth: 0,
charWidth: 0,
windowWidth: 0,

View file

@ -3,11 +3,12 @@ import * as actions from 'state/actions';
const initialState = {
results: [],
end: false
end: false,
topCache: {}
};
export default createReducer(initialState, {
[actions.socket.CHANNEL_SEARCH](state, { results, start }) {
[actions.socket.CHANNEL_SEARCH](state, { results, start, server, q }) {
if (results) {
state.end = false;
@ -15,15 +16,20 @@ export default createReducer(initialState, {
state.results.push(...results);
} else {
state.results = results;
if (!q) {
state.topCache[server] = results;
}
}
} else {
state.end = true;
}
},
[actions.OPEN_MODAL](state, { name }) {
[actions.OPEN_MODAL](state, { name, payload }) {
if (name === 'channel') {
return initialState;
state.results = state.topCache[payload] || [];
state.end = false;
}
}
});