Add defaultchannel query parameter to embed to set default embed channel

This commit is contained in:
Jeremy Zhang 2017-07-18 04:46:26 +00:00
parent 0a18bec418
commit 9c5abd9b54

View File

@ -273,17 +273,33 @@
if (guildobj === undefined) { if (guildobj === undefined) {
var guild = query_guild(); var guild = query_guild();
guild.done(function(data) { guild.done(function(data) {
switch_to_default_channel(data.channels);
prepare_guild(data); prepare_guild(data);
$('#loginmodal').modal('close'); $('#loginmodal').modal('close');
unlock_login_fields(); unlock_login_fields();
}); });
} else { } else {
switch_to_default_channel(guildobj.channels);
prepare_guild(guildobj); prepare_guild(guildobj);
$('#loginmodal').modal('close'); $('#loginmodal').modal('close');
unlock_login_fields(); unlock_login_fields();
} }
} }
function switch_to_default_channel(guildchannels) {
var defaultChannel = getParameterByName("defaultchannel");
if (!defaultChannel) {
return;
}
for (var i = 0; i < guildchannels.length; i++) {
if (guildchannels[i].channel.id == defaultChannel) {
selected_channel = defaultChannel;
debugger;
return;
}
}
}
function prepare_guild(guildobj) { function prepare_guild(guildobj) {
emoji_store = guildobj.emojis; emoji_store = guildobj.emojis;
fill_channels(guildobj.channels); fill_channels(guildobj.channels);