refactor: 调整初始化代码结构

pull/13/head
moonrailgun 4 years ago
parent ad8bef67b7
commit 229a037275

@ -3,13 +3,20 @@ import type { AppSocket } from '../api/socket';
import { chatActions, userActions } from './slices';
import type { FriendRequest } from '../model/friend';
import type { UserDMList } from '../model/user';
import { fetchConverseInfo } from '../model/converse';
import { getCachedConverseInfo } from '../cache/cache';
/**
* Redux
*/
export function setupRedux(socket: AppSocket, store: AppStore) {
initial(socket, store);
listenNotify(socket, store);
}
/**
*
*/
function initial(socket: AppSocket, store: AppStore) {
console.log('初始化Redux上下文...');
// 获取好友列表
@ -30,9 +37,12 @@ export function setupRedux(socket: AppSocket, store: AppStore) {
store.dispatch(chatActions.setConverseInfo(converse));
});
});
}
// ------------------ 通知
/**
*
*/
function listenNotify(socket: AppSocket, store: AppStore) {
socket.listen<{ userId: string }>('friend.add', ({ userId }) => {
if (typeof userId !== 'string') {
console.error('错误的信息', userId);

Loading…
Cancel
Save