Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf8e12f5

Browse files
committed
Handle channel forwarding and errors better
1 parent4979348 commitf8e12f5

File tree

15 files changed

+481
-213
lines changed

15 files changed

+481
-213
lines changed

‎assets/bindata.go‎

Lines changed: 118 additions & 118 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎client/css/style.css‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ i[class*=' icon-']:before {
149149
color:#f6546a!important;
150150
}
151151

152+
.disabled {
153+
color:#999!important;
154+
}
155+
152156
.textinput {
153157
display: block;
154158
position: relative;

‎client/js/components/TabList.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
importReact,{PureComponent}from'react';
22
importclassnamesfrom'classnames';
33
importButtonfrom'components/ui/Button';
4-
importTabListItemfrom'./TabListItem';
4+
importTabListItemfrom'containers/TabListItem';
55

66
exportdefaultclassTabListextendsPureComponent{
77
handleTabClick=(server,target)=>this.props.select(server,target);

‎client/js/components/TabListItem.js‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
importReact,{memo}from'react';
1+
importReactfrom'react';
22
importclassnamesfrom'classnames';
33

44
constTabListItem=({
@@ -7,12 +7,15 @@ const TabListItem = ({
77
server,
88
selected,
99
connected,
10+
joined,
11+
error,
1012
onClick
1113
})=>{
1214
constclassName=classnames({
1315
'tab-server':!target,
1416
success:!target&&connected,
15-
error:!target&&!connected,
17+
error:(!target&&!connected)||(!joined&&error),
18+
disabled:!!target&&!error&&joined===false,
1619
selected
1720
});
1821

@@ -23,4 +26,4 @@ const TabListItem = ({
2326
);
2427
};
2528

26-
exportdefaultmemo(TabListItem);
29+
exportdefaultTabListItem;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import{createStructuredSelector}from'reselect';
2+
importgetfrom'lodash/get';
3+
importTabListItemfrom'components/TabListItem';
4+
importconnectfrom'utils/connect';
5+
6+
constmapState=createStructuredSelector({
7+
joined:(state,{ server, target})=>
8+
get(state,['channels',server,target,'joined']),
9+
10+
error:(state,{ server, target})=>{
11+
constmessages=get(state,['messages',server,target]);
12+
13+
if(messages&&messages.length>0){
14+
returnmessages[messages.length-1].type==='error';
15+
}
16+
returnfalse;
17+
}
18+
});
19+
20+
exportdefaultconnect(mapState)(TabListItem);

‎client/js/modules/socket.js‎

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import{openModal}from'state/modals';
1111
import{reconnect}from'state/servers';
1212
import{select}from'state/tab';
13-
import{find,normalizeChannel}from'utils';
13+
import{find}from'utils';
1414

1515
functionwithReason(message,reason){
1616
returnmessage+(reason ?` (${reason})` :'');
@@ -46,22 +46,7 @@ export default function handleSocket({
4646
},
4747

4848
join({ user, server, channels}){
49-
conststate=getState();
50-
consttab=state.tab.selected;
51-
const[joinedChannel]=channels;
52-
if(tab.server&&tab.name){
53-
const{ nick}=state.servers[tab.server];
54-
if(
55-
tab.server===server&&
56-
nick===user&&
57-
tab.name!==joinedChannel&&
58-
normalizeChannel(tab.name)===normalizeChannel(joinedChannel)
59-
){
60-
dispatch(select(server,joinedChannel));
61-
}
62-
}
63-
64-
dispatch(inform(`${user} joined the channel`,server,joinedChannel));
49+
dispatch(inform(`${user} joined the channel`,server,channels[0]));
6550
},
6651

6752
part({ user, server, channel, reason}){
@@ -123,6 +108,10 @@ export default function handleSocket({
123108
dispatch(addMessage(message,tab.server,tab.name));
124109
},
125110

111+
error({ server, target, message}){
112+
dispatch(addMessage({content:message,type:'error'},server,target));
113+
},
114+
126115
connection_update({ server, errorType}){
127116
if(errorType==='verify'){
128117
dispatch(
@@ -145,6 +134,16 @@ export default function handleSocket({
145134
}
146135
};
147136

137+
constafterHandlers={
138+
channel_forward(forward){
139+
const{ selected}=getState().tab;
140+
141+
if(selected.server===forward.server&&selected.name===forward.old){
142+
dispatch(select(forward.server,forward.new,true));
143+
}
144+
}
145+
};
146+
148147
socket.onMessage((type,data)=>{
149148
letaction;
150149
if(Array.isArray(data)){
@@ -162,5 +161,9 @@ export default function handleSocket({
162161
}
163162

164163
dispatch(action);
164+
165+
if(typeinafterHandlers){
166+
afterHandlers[type](data);
167+
}
165168
});
166169
}

‎client/js/state/actions.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ export const socket = createSocketActions([
6666
'cert_fail',
6767
'cert_success',
6868
'channels',
69+
'channel_forward',
6970
'channel_search',
7071
'connection_update',
72+
'error',
7173
'join',
7274
'message',
7375
'mode',

‎client/js/state/channels.js‎

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ export default createReducer(
140140
state[server][channel].users.push(createUser(user));
141141
},
142142

143+
[actions.socket.CHANNEL_FORWARD](state,action){
144+
init(state,action.server,action.new);
145+
deletestate[action.server][action.old];
146+
},
147+
143148
[actions.socket.PART](state,{ server, channel, user}){
144149
if(state[server][channel]){
145150
removeUser(state[server][channel].users,user);
@@ -230,16 +235,27 @@ export function join(channels, server) {
230235
}
231236

232237
exportfunctionpart(channels,server){
233-
returndispatch=>{
234-
dispatch({
238+
return(dispatch,getState)=>{
239+
constaction={
235240
type:actions.PART,
236241
channels,
237-
server,
238-
socket:{
242+
server
243+
};
244+
245+
conststate=getState().channels[server];
246+
constjoined=channels.filter(c=>state[c]&&state[c].joined);
247+
248+
if(joined.length>0){
249+
action.socket={
239250
type:'part',
240-
data:{ channels, server}
241-
}
242-
});
251+
data:{
252+
channels:joined,
253+
server
254+
}
255+
};
256+
}
257+
258+
dispatch(action);
243259
dispatch(updateSelection());
244260
};
245261
}

‎client/js/state/messages.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ export default createReducer(
140140
channels.forEach(channel=>deletestate[server][channel]);
141141
},
142142

143+
[actions.socket.CHANNEL_FORWARD](state,{ server, old}){
144+
if(state[server]){
145+
deletestate[server][old];
146+
}
147+
},
148+
143149
[actions.UPDATE_MESSAGE_HEIGHT](
144150
state,
145151
{ wrapWidth, charWidth, windowWidth}

‎pkg/irc/const.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ const (
3939
ReplyEndOfMotd="376"
4040
ErrErroneousNickname="432"
4141
ErrNicknameInUse="433"
42+
ErrForward="470"
4243
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp