Implement switchToChannel method.
This commit is contained in:
parent
e845e17a63
commit
2049a16d64
@ -82,8 +82,7 @@ export default {
|
|||||||
return this.channel.name;
|
return this.channel.name;
|
||||||
},
|
},
|
||||||
click() {
|
click() {
|
||||||
// TODO: Find out why this sometimes throws `uncaught exception: Object`
|
this.$root.switchToChannel(this.channel);
|
||||||
this.$router.push("chan-" + this.channel.id);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -18,7 +18,7 @@ export default {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (existingChannel) {
|
if (existingChannel) {
|
||||||
this.$router.push("chan-" + existingChannel.id);
|
this.$root.switchToChannel(existingChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Required here because it breaks tests
|
// TODO: Required here because it breaks tests
|
||||||
|
@ -65,7 +65,7 @@ export default {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (existingChannel) {
|
if (existingChannel) {
|
||||||
this.$router.push("chan-" + existingChannel.id);
|
this.$root.switchToChannel(existingChannel);
|
||||||
} else {
|
} else {
|
||||||
const chanTypes = this.network.serverOptions.CHANTYPES;
|
const chanTypes = this.network.serverOptions.CHANTYPES;
|
||||||
let channel = this.inputChannel;
|
let channel = this.inputChannel;
|
||||||
|
@ -25,7 +25,7 @@ exports.input = function(args) {
|
|||||||
const chan = utils.findCurrentNetworkChan(channels);
|
const chan = utils.findCurrentNetworkChan(channels);
|
||||||
|
|
||||||
if (chan) {
|
if (chan) {
|
||||||
vueApp.$router.push("chan-" + chan.id);
|
vueApp.switchToChannel(chan);
|
||||||
} else {
|
} else {
|
||||||
socket.emit("input", {
|
socket.emit("input", {
|
||||||
text: `/join ${channels} ${args.length > 1 ? args[1] : ""}`,
|
text: `/join ${channels} ${args.length > 1 ? args[1] : ""}`,
|
||||||
|
@ -50,7 +50,7 @@ function addWhoisItem() {
|
|||||||
const chan = utils.findCurrentNetworkChan(itemData);
|
const chan = utils.findCurrentNetworkChan(itemData);
|
||||||
|
|
||||||
if (chan) {
|
if (chan) {
|
||||||
vueApp.$router.push("chan-" + chan.id);
|
vueApp.switchToChannel(chan);
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit("input", {
|
socket.emit("input", {
|
||||||
@ -85,7 +85,7 @@ function addQueryItem() {
|
|||||||
const chan = utils.findCurrentNetworkChan(itemData);
|
const chan = utils.findCurrentNetworkChan(itemData);
|
||||||
|
|
||||||
if (chan) {
|
if (chan) {
|
||||||
vueApp.$router.push("chan-" + chan.id);
|
vueApp.switchToChannel(chan);
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit("input", {
|
socket.emit("input", {
|
||||||
|
@ -90,7 +90,7 @@ Mousetrap.bind(["alt+a"], function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (targetchan) {
|
if (targetchan) {
|
||||||
vueApp.$router.push("chan-" + targetchan.id);
|
vueApp.switchToChannel(targetchan);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -15,5 +15,5 @@ socket.on("join", function(data) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
vueApp.$router.push("chan-" + data.chan.id);
|
vueApp.switchToChannel(vueApp.findChannel(data.chan.id));
|
||||||
});
|
});
|
||||||
|
@ -4,6 +4,7 @@ const socket = require("../socket");
|
|||||||
const {vueApp, findChannel} = require("../vue");
|
const {vueApp, findChannel} = require("../vue");
|
||||||
|
|
||||||
socket.on("msg:special", function(data) {
|
socket.on("msg:special", function(data) {
|
||||||
findChannel(data.chan).channel.data = data.data;
|
const channel = findChannel(data.chan);
|
||||||
vueApp.$router.push("chan-" + data.chan);
|
channel.channel.data = data.data;
|
||||||
|
vueApp.switchToChannel(channel.channel);
|
||||||
});
|
});
|
||||||
|
@ -12,7 +12,7 @@ socket.on("network", function(data) {
|
|||||||
network.channels.forEach(initChannel);
|
network.channels.forEach(initChannel);
|
||||||
|
|
||||||
vueApp.networks.push(network);
|
vueApp.networks.push(network);
|
||||||
vueApp.$router.push("chan-" + network.channels[0].id);
|
vueApp.switchToChannel(network.channels[0]);
|
||||||
|
|
||||||
$("#connect")
|
$("#connect")
|
||||||
.find(".btn")
|
.find(".btn")
|
||||||
|
@ -6,7 +6,7 @@ const {vueApp, findChannel} = require("../vue");
|
|||||||
socket.on("part", function(data) {
|
socket.on("part", function(data) {
|
||||||
// When parting from the active channel/query, jump to the network's lobby
|
// When parting from the active channel/query, jump to the network's lobby
|
||||||
if (vueApp.activeChannel && vueApp.activeChannel.channel.id === data.chan) {
|
if (vueApp.activeChannel && vueApp.activeChannel.channel.id === data.chan) {
|
||||||
vueApp.$router.push("chan-" + vueApp.activeChannel.network.id);
|
vueApp.switchToChannel(vueApp.activeChannel.network);
|
||||||
}
|
}
|
||||||
|
|
||||||
const channel = findChannel(data.chan);
|
const channel = findChannel(data.chan);
|
||||||
|
@ -102,6 +102,13 @@ const vueApp = new Vue({
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
switchToChannel(channel) {
|
||||||
|
if (this.activeChannel && this.activeChannel.channel.id === channel.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$router.push("chan-" + channel.id);
|
||||||
|
},
|
||||||
switchOutOfChannel(channel) {
|
switchOutOfChannel(channel) {
|
||||||
// When switching out of a channel, mark everything as read
|
// When switching out of a channel, mark everything as read
|
||||||
if (channel.messages.length > 0) {
|
if (channel.messages.length > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user