fixed login page login & create functionality

This commit is contained in:
bill bittner 2017-10-10 18:05:47 -07:00
parent c65082e610
commit 3dfbac8d71
3 changed files with 31 additions and 9 deletions

View file

@ -32,10 +32,14 @@ function publishNewChannel (event) {
setUserCookies(result.channelName, result.channelClaimId, result.shortChannelId); // set cookies setUserCookies(result.channelName, result.channelClaimId, result.shortChannelId); // set cookies
}) })
.then(() => { .then(() => {
// remove old channel and replace with new one & select it if (window.location.pathname === '/') {
replaceChannelOptionInPublishChannelSelect(); // remove old channel and replace with new one & select it
// remove old channel and replace with new one & select it replaceChannelOptionInPublishChannelSelect();
replaceChannelOptionInNavBarChannelSelect(); // remove old channel and replace with new one & select it
replaceChannelOptionInNavBarChannelSelect();
} else {
window.location = '/';
}
}) })
.catch(error => { .catch(error => {
if (error.name === 'ChannelNameError'){ if (error.name === 'ChannelNameError'){

View file

@ -55,10 +55,15 @@ function loginToChannel (event) {
}) })
// update channel selection // update channel selection
.then(() => { .then(() => {
// remove old channel and replace with new one & select it if (window.location.pathname === '/') {
replaceChannelOptionInPublishChannelSelect(); // remove old channel and replace with new one & select it
// remove old channel and replace with new one & select it replaceChannelOptionInPublishChannelSelect();
replaceChannelOptionInNavBarChannelSelect(); // remove old channel and replace with new one & select it
replaceChannelOptionInNavBarChannelSelect();
} else {
window.location = '/';
}
}) })
.catch(error => { .catch(error => {
const loginErrorDisplayElement = document.getElementById('login-error-display-element'); const loginErrorDisplayElement = document.getElementById('login-error-display-element');

View file

@ -14,4 +14,17 @@
<a id="nav-bar-login-link" class="nav-bar-link" href="/login" {{#if user}}style="display:none"{{/if}}>Channel</a> <a id="nav-bar-login-link" class="nav-bar-link" href="/login" {{#if user}}style="display:none"{{/if}}>Channel</a>
</div> </div>
</div> </div>
</div> </div>
<script type="text/javascript">
// highlight the link for the current page
const navBarLinks = document.getElementsByClassName('nav-bar-link');
for (let i = 0; i < navBarLinks.length; i++){
const link = navBarLinks[i];
if (link.href == window.location.href) {
link.setAttribute('class', 'nav-bar-link nav-bar-link--active');
} else if (`/${link.value}` === window.location.pathname) {
link.setAttribute('class', 'select select--no-arrow nav-bar-link nav-bar-link--active');
}
}
</script>