update iris-lib, fix signup by pressing enter

This commit is contained in:
Martti Malmi 2020-04-06 15:17:25 +03:00
parent a757b75f9c
commit 0f8e7420de
3 changed files with 486 additions and 255 deletions

View File

@ -62,16 +62,16 @@
<div class="chat">
<section id="login" class="hidden">
<div id="login-content">
<div id="login-form" autocomplete="off">
<form id="login-form" autocomplete="off">
<div id="create-account">
<img style="width: 86px" src="img/android-chrome-192x192.png" alt="Iris">
<h1>Iris Messenger</h1>
<input autofocus autocomplete="off" autocorrect="off" autocapitalize="sentences" spellcheck="off" id="login-form-name" type="text" name="name" placeholder="What's your name?">
<p><button id="sign-up" type="input">Go</button></p>
<p><button id="sign-up" type="submit">Go</button></p>
<br>
<p><a href="#" id="show-existing-account-login">Already have an account?</a></p>
</div>
</div>
</form>
<div id="existing-account-login" class="hidden">
<p><a href="#" id="show-create-account">&lt; Back</a></p>
<input id="paste-privkey" placeholder="Paste a private key">

View File

@ -130,7 +130,8 @@ async function addPeer(peer) {
function newUserLogin() {
$('#login').show();
$('#login-form-name').focus();
$('#sign-up').click(function() {
$('#login-form').submit(function(e) {
e.preventDefault();
var name = $('#login-form-name').val();
if (name.length) {
$('#login').hide();
@ -148,13 +149,13 @@ function login(k) {
key = k;
localStorage.setItem('chatKeyPair', JSON.stringify(k));
$('#login').hide();
iris.Chat.initUser(gun, key);
iris.Channel.initUser(gun, key);
$('#my-chat-links').empty();
iris.Chat.getMyChatLinks(gun, key, undefined, chatLink => {
iris.Channel.getMyChannelLinks(gun, key, undefined, chatLink => {
var row = $('<div>').addClass('flex-row');
var text = $('<div>').addClass('flex-cell').text(chatLink.url);
var btn = $('<button>Remove</button>').click(() => {
iris.Chat.removeChatLink(gun, key, chatLink.id);
iris.Channel.removeChannelLink(gun, key, chatLink.id);
hideAndRemove(row);
});
row.append(text);
@ -178,7 +179,7 @@ function login(k) {
}
});
setOurOnlineStatus();
iris.Chat.getChats(gun, key, addChat);
iris.Channel.getChannels(gun, key, addChat);
var chatWith = getUrlParameter('chatWith');
if (chatWith) {
addChat(chatWith, window.location.href);
@ -223,7 +224,7 @@ function login(k) {
}
async function createChatLink() {
latestChatLink = await iris.Chat.createChatLink(gun, key);
latestChatLink = await iris.Channel.createChannelLink(gun, key);
setChatLinkQrCode(latestChatLink);
}
@ -344,24 +345,24 @@ $('#settings-about').on('input', event => {
});
function setOurOnlineStatus() {
iris.Chat.setOnline(gun, areWeOnline = true);
iris.Channel.setOnline(gun, areWeOnline = true);
document.addEventListener("mousemove", () => {
if (!areWeOnline && activeChat) {
chats[activeChat].setMyMsgsLastSeenTime();
}
iris.Chat.setOnline(gun, areWeOnline = true);
iris.Channel.setOnline(gun, areWeOnline = true);
clearTimeout(onlineTimeout);
onlineTimeout = setTimeout(() => iris.Chat.setOnline(gun, areWeOnline = false), 60000);
onlineTimeout = setTimeout(() => iris.Channel.setOnline(gun, areWeOnline = false), 60000);
});
document.addEventListener("visibilitychange", () => {
if (document.visibilityState === 'visible') {
iris.Chat.setOnline(gun, areWeOnline = true);
iris.Channel.setOnline(gun, areWeOnline = true);
if (activeChat) {
chats[activeChat].setMyMsgsLastSeenTime();
changeChatUnseenCount(activeChat, 0);
}
} else {
iris.Chat.setOnline(gun, areWeOnline = false);
iris.Channel.setOnline(gun, areWeOnline = false);
}
});
}
@ -884,7 +885,7 @@ function addMessage(msg) {
}
function deleteChat(pub) {
iris.Chat.deleteChat(gun, key, pub);
iris.Channel.deleteChannel(gun, key, pub);
if (activeChat === pub) {
showNewChat();
showMenu();
@ -902,7 +903,7 @@ function addChat(pub, chatLink) {
el.attr('data-pub', pub);
var latestEl = el.find('.latest');
var typingIndicator = el.find('.typing-indicator').text('Typing...');
chats[pub] = new iris.Chat({gun, key, chatLink: chatLink, participants: pub, onMessage: (msg, info) => {
chats[pub] = new iris.Channel({gun, key, chatLink: chatLink, participants: pub, onMessage: (msg, info) => {
msg.selfAuthored = info.selfAuthored;
chats[pub].messages[msg.time] = msg;
msg.time = new Date(msg.time);
@ -1007,7 +1008,7 @@ function addChat(pub, chatLink) {
latestEl.toggle(!isTyping);
});
chats[pub].online = {};
iris.Chat.getOnline(gun, pub, (online) => {
iris.Channel.getOnline(gun, pub, (online) => {
if (chats[pub]) {
chats[pub].online = online;
setTheirOnlineStatus(pub);

File diff suppressed because it is too large Load Diff