Skip to content

Commit e6542c5

Browse files
authored
Bugfix: [v3] Fix to active disableAutoSelect props (#152)
Apply disableAutoSelect props in the channel list init step
1 parent a2b9512 commit e6542c5

File tree

6 files changed

+14
-23
lines changed

6 files changed

+14
-23
lines changed

src/smart-components/App/stories/index.stories.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ export const user2 = () => fitPageSize(
243243
config={{ logLevel: 'all', userMention: { maxMentionCount: 2, maxSuggestionCount: 5 } }}
244244
replyType="QUOTE_REPLY"
245245
useMessageGrouping={false}
246+
disableAutoSelect
246247
imageCompression={{
247248
compressionRate: 0.5,
248249
resizingWidth: 100,

src/smart-components/ChannelList/context/ChannelListProvider.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ interface ChannelListStoreInterface {
9595
showSettings: boolean;
9696
channelListQuery: GroupChannelListQuery;
9797
currentUserId: string;
98+
disableAutoSelect: boolean;
9899
}
99100

100101
const ChannelListContext = React.createContext<ChannelListProviderInterface | null>({
@@ -176,13 +177,6 @@ const ChannelListProvider: React.FC<ChannelListProviderProps> = (props: ChannelL
176177
};
177178
}, [sdkIntialized]);
178179

179-
useEffect(() => {
180-
channelListDispatcher({
181-
type: channelListActions.SET_AUTO_SELECT_CHANNEL_ITEM,
182-
payload: disableAutoSelect,
183-
});
184-
}, [disableAutoSelect]);
185-
186180
useEffect(() => {
187181
setSdkChannelHandlerId(uuidv4);
188182
if (sdkIntialized) {

src/smart-components/ChannelList/dux/__tests__/reducers.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('Channels-Reducers', () => {
88
it('should set channels on INIT_CHANNELS_SUCCESS', () => {
99
const nextState = reducers(initialState, {
1010
type: actionTypes.INIT_CHANNELS_SUCCESS,
11-
payload: mockData.allChannels,
11+
payload: { channelList: mockData.allChannels },
1212
});
1313

1414
expect(nextState.initialized).toEqual(true);

src/smart-components/ChannelList/dux/actionTypes.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ export const RESET_CHANNEL_LIST = 'RESET_CHANNEL_LIST';
22
export const CREATE_CHANNEL = 'CREATE_CHANNEL';
33
export const UNLOAD_CHANNELS = 'UNLOAD_CHANNELS';
44
export const SET_CHANNEL_LOADING = 'SET_CHANNEL_LOADING';
5-
export const SET_AUTO_SELECT_CHANNEL_ITEM = 'SET_AUTO_SELECT_CHANNEL_ITEM';
65
export const LEAVE_CHANNEL_SUCCESS = 'LEAVE_CHANNEL_SUCCESS';
76

87
export const SET_CURRENT_CHANNEL = 'SET_CURRENT_CHANNEL';

src/smart-components/ChannelList/dux/reducers.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,24 @@ export default function reducer(state, action) {
1111
};
1212
case actions.RESET_CHANNEL_LIST:
1313
return initialState;
14-
case actions.INIT_CHANNELS_SUCCESS:
14+
case actions.INIT_CHANNELS_SUCCESS: {
15+
const { channelList, disableAutoSelect } = action.payload;
1516
return {
1617
...state,
1718
initialized: true,
1819
loading: false,
19-
allChannels: action.payload,
20+
allChannels: channelList,
21+
disableAutoSelect,
2022
currentChannel: (
21-
!state.disableAutoSelect
22-
&& action.payload
23-
&& action.payload.length
24-
&& action.payload.length > 0
23+
!disableAutoSelect
24+
&& channelList
25+
&& channelList.length
26+
&& channelList.length > 0
2527
)
26-
? action.payload[0]
28+
? channelList[0]
2729
: null,
2830
};
31+
}
2932
case actions.FETCH_CHANNELS_SUCCESS: {
3033
const currentChannels = state.allChannels.map((c) => c.url);
3134
const filteredChannels = action.payload.filter(
@@ -265,12 +268,6 @@ export default function reducer(state, action) {
265268
currentUserId: action.payload.currentUserId,
266269
channelListQuery: action.payload.channelListQuery,
267270
};
268-
case actions.SET_AUTO_SELECT_CHANNEL_ITEM: {
269-
return {
270-
...state,
271-
ableAutoSelect: action.payload,
272-
};
273-
}
274271
default:
275272
return state;
276273
}

src/smart-components/ChannelList/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ function setupChannelList({
217217
}
218218
channelListDispatcher({
219219
type: channelActions.INIT_CHANNELS_SUCCESS,
220-
payload: sortedChannelList,
220+
payload: { channelList: sortedChannelList, disableAutoSelect },
221221
});
222222
const canSetMarkAsDelivered = sdk?.appInfo?.premiumFeatureList
223223
?.find((feature) => (feature === DELIVERY_RECIPT));

0 commit comments

Comments
 (0)