Refactor ISUPPORT handling
Add a helper class to parse ISUPPORT tokens. Instead of having manual ISUPPORT handling all over the place, use pre-processed values.
This commit is contained in:
@@ -718,7 +718,7 @@ export default class App extends Component {
|
||||
target = SERVER_BUFFER;
|
||||
}
|
||||
|
||||
let allowedPrefixes = client.isupport.get("STATUSMSG");
|
||||
let allowedPrefixes = client.isupport.statusMsg();
|
||||
if (allowedPrefixes) {
|
||||
let parts = irc.parseTargetPrefix(target, allowedPrefixes);
|
||||
if (client.isChannel(parts.name)) {
|
||||
@@ -890,7 +890,7 @@ export default class App extends Component {
|
||||
|
||||
// Auto-join channels given at connect-time
|
||||
let server = this.state.servers.get(serverID);
|
||||
let bouncerNetID = server.isupport.get("BOUNCER_NETID");
|
||||
let bouncerNetID = server.bouncerNetID;
|
||||
let bouncerNetwork = null;
|
||||
if (bouncerNetID) {
|
||||
bouncerNetwork = this.state.bouncerNetworks.get(bouncerNetID);
|
||||
@@ -936,7 +936,7 @@ export default class App extends Component {
|
||||
break; // We're only interested in network updates
|
||||
}
|
||||
|
||||
if (client.isupport.has("BOUNCER_NETID")) {
|
||||
if (client.isupport.bouncerNetID()) {
|
||||
// This can happen if the user has specified a network to bind
|
||||
// to via other means, e.g. "<username>/<network>".
|
||||
break;
|
||||
@@ -1081,7 +1081,7 @@ export default class App extends Component {
|
||||
}
|
||||
|
||||
for (let [id, server] of this.state.servers) {
|
||||
if (server.isupport.get("BOUNCER_NETID") === bouncerNetID) {
|
||||
if (server.bouncerNetID === bouncerNetID) {
|
||||
serverID = id;
|
||||
break;
|
||||
}
|
||||
@@ -1529,7 +1529,7 @@ export default class App extends Component {
|
||||
|
||||
handleManageNetworkClick(serverID) {
|
||||
let server = this.state.servers.get(serverID);
|
||||
let bouncerNetID = server.isupport.get("BOUNCER_NETID");
|
||||
let bouncerNetID = server.bouncerNetID;
|
||||
let bouncerNetwork = this.state.bouncerNetworks.get(bouncerNetID);
|
||||
this.openDialog("network", {
|
||||
id: bouncerNetID,
|
||||
@@ -1599,7 +1599,7 @@ export default class App extends Component {
|
||||
let activeClient = this.clients.get(activeBuffer.server);
|
||||
isBouncer = activeClient && activeClient.enabledCaps["soju.im/bouncer-networks"];
|
||||
|
||||
let bouncerNetID = activeServer.isupport.get("BOUNCER_NETID");
|
||||
let bouncerNetID = activeServer.bouncerNetID;
|
||||
if (bouncerNetID) {
|
||||
activeBouncerNetwork = this.state.bouncerNetworks.get(bouncerNetID);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ export default function BufferHeader(props) {
|
||||
`;
|
||||
|
||||
if (props.isBouncer) {
|
||||
if (props.server.isupport.get("BOUNCER_NETID")) {
|
||||
if (props.server.bouncerNetID) {
|
||||
if (fullyConnected) {
|
||||
actions.push(joinButton);
|
||||
}
|
||||
@@ -186,7 +186,7 @@ export default function BufferHeader(props) {
|
||||
item = `authenticated as ${props.user.account}`;
|
||||
}
|
||||
details.push(html`<abbr title=${desc}>${item}</abbr>`);
|
||||
} else if (props.server.isupport.has("MONITOR") && props.server.isupport.has("WHOX")) {
|
||||
} else if (props.server.reliableUserAccounts) {
|
||||
// If the server supports MONITOR and WHOX, we can faithfully
|
||||
// keep user.account up-to-date for user queries
|
||||
let desc = "This user has not been verified and is not logged in.";
|
||||
|
||||
@@ -44,7 +44,7 @@ export default function BufferList(props) {
|
||||
let server = props.servers.get(buf.server);
|
||||
|
||||
let bouncerNetwork = null;
|
||||
let bouncerNetID = server.isupport.get("BOUNCER_NETID");
|
||||
let bouncerNetID = server.bouncerNetID;
|
||||
if (bouncerNetID) {
|
||||
bouncerNetwork = props.bouncerNetworks.get(bouncerNetID);
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ class LogLine extends Component {
|
||||
}
|
||||
|
||||
let status = null;
|
||||
let allowedPrefixes = server.isupport.get("STATUSMSG");
|
||||
let allowedPrefixes = server.statusMsg;
|
||||
if (target !== buf.name && allowedPrefixes) {
|
||||
let parts = irc.parseTargetPrefix(target, allowedPrefixes);
|
||||
if (parts.name === buf.name) {
|
||||
@@ -487,8 +487,8 @@ class ProtocolHandlerNagger extends Component {
|
||||
|
||||
function AccountNagger({ server, onAuthClick, onRegisterClick }) {
|
||||
let accDesc = "an account on this server";
|
||||
if (server.isupport.has("NETWORK")) {
|
||||
accDesc = "a " + server.isupport.get("NETWORK") + " account";
|
||||
if (server.name) {
|
||||
accDesc = "a " + server.name + " account";
|
||||
}
|
||||
|
||||
function handleAuthClick(event) {
|
||||
@@ -564,13 +564,13 @@ export default class Buffer extends Component {
|
||||
|
||||
let server = this.props.server;
|
||||
let bouncerNetwork = this.props.bouncerNetwork;
|
||||
let serverName = server.isupport.get("NETWORK");
|
||||
let serverName = server.name;
|
||||
|
||||
let children = [];
|
||||
if (buf.type == BufferType.SERVER) {
|
||||
children.push(html`<${NotificationNagger}/>`);
|
||||
}
|
||||
if (buf.type == BufferType.SERVER && this.props.isBouncer && !server.isupport.has("BOUNCER_NETID")) {
|
||||
if (buf.type == BufferType.SERVER && this.props.isBouncer && !server.bouncerNetID) {
|
||||
children.push(html`<${ProtocolHandlerNagger} bouncerName=${serverName}/>`);
|
||||
}
|
||||
if (buf.type == BufferType.SERVER && server.status == ServerStatus.REGISTERED && server.supportsSASLPlain && !server.account) {
|
||||
|
||||
Reference in New Issue
Block a user