diff --git a/app/lib/queries.js b/app/lib/queries.js index 72aa379..259927d 100644 --- a/app/lib/queries.js +++ b/app/lib/queries.js @@ -239,24 +239,43 @@ const searchPeople = (ssbServer, search) => const getFriends = async (ssbServer, profile) => { debugFriends("Fetching"); - let followingPromise = new Promise((resolve, reject) => { + let contacts = await new Promise((resolve, reject) => { pull( - ssbServer.query.read({ - reverse: true, - query: [ - { - $filter: { - value: { - author: profile.id, - content: { - type: "contact", + // @ts-ignore + cat([ + ssbServer.query.read({ + reverse: true, + query: [ + { + $filter: { + value: { + author: profile.id, + content: { + type: "contact", + }, }, }, }, - }, - ], - limit: 100, - }), + ], + limit: 100, + }), + ssbServer.query.read({ + reverse: true, + query: [ + { + $filter: { + value: { + content: { + type: "contact", + contact: profile.id, + }, + }, + }, + }, + ], + limit: 100, + }), + ]), pull.collect((err, msgs) => { const entries = msgs.map((x) => x.value); @@ -266,42 +285,8 @@ const getFriends = async (ssbServer, profile) => { ); }); - let followersPromise = new Promise((resolve, reject) => { - pull( - ssbServer.query.read({ - reverse: true, - query: [ - { - $filter: { - value: { - content: { - type: "contact", - contact: profile.id, - }, - }, - }, - }, - ], - limit: 100, - }), - pull.collect((err, msgs) => { - const entries = msgs.map((x) => x.value); - - if (err) return reject(err); - return resolve(entries); - }) - ); - }); - - const [following, followers] = await Promise.all([ - followingPromise, - followersPromise, - ]); - - const allContacts = following.concat(followers).reverse(); - let network = {}; - for (let contact of allContacts) { + for (let contact of contacts.reverse()) { if (contact.content.following) { network[contact.author] = network[contact.author] || {}; network[contact.author][contact.content.contact] = true; diff --git a/app/public/js/index.js b/app/public/js/index.js index 3c6f05f..faeef6a 100644 --- a/app/public/js/index.js +++ b/app/public/js/index.js @@ -18,7 +18,7 @@ messages.forEach((message) => { const parent = modal.parentElement; parent.parentElement.removeChild(parent); if (document.querySelectorAll(".vanishing-message").length == 0) { - document.querySelector(".vanishing-messages").style.display = "none"; + document.querySelector(".js-vanishing-messages").style.display = "none"; } }; diff --git a/app/public/style.css b/app/public/style.css index df8f514..30f9082 100644 --- a/app/public/style.css +++ b/app/public/style.css @@ -170,20 +170,29 @@ h2 { width: 300px; } -button.vanishing-message { +.notifications { + display: flex; + align-content: flex-start; +} + +a.notification-box, +button.notification-box { background: none; - width: 84px; text-align: center; border: 1px solid #333; - padding: 10px; cursor: pointer; color: #000; margin-right: 8px; + padding: 5px; + text-decoration: none; + display: inline-block; + border-radius: 3px; } -button.vanishing-message:hover { - background: #ddd; - color: #5f5f5f; +a.notification-box:hover, +button.notification-box:hover { + background: #e2e2e2; + color: #000; } .overlay { diff --git a/app/views/home.ejs b/app/views/home.ejs index 7cb655a..29f65c8 100644 --- a/app/views/home.ejs +++ b/app/views/home.ejs @@ -23,38 +23,40 @@
<% if (vanishingMessages.length > 0) { %> -
+

Vanishing Messages

- <% vanishingMessages.reverse().map(message => { %> - - -
- <% } %> <% if (friends.requests_received) { %> -
-

Friend Requests

+

Friend Requests

+
<% friends.requests_received.map(friend => { %> - +
<%= friend.name %>