From e897a4c99d25f8386b687dc837f91e3c90fe2428 Mon Sep 17 00:00:00 2001 From: Bastard Operator Date: Sun, 10 Jan 2021 19:34:43 +0100 Subject: [PATCH] Finished implementing Meet Account discard: * Now showing "nothing to show" message when there is noone in the timeline to meet * Fixed account view click not showing accounts correctly after discarding * Improved UI on Meet account --- src/routes/_actions/accounts.js | 11 --------- src/routes/_actions/timeline.js | 4 ---- src/routes/_api/timelines.js | 4 ---- src/scss/themes/ozark.scss | 18 +++++++++++++++ static/fedilove-no-react.js | 41 ++++++++++++++++++++++++--------- 5 files changed, 48 insertions(+), 30 deletions(-) diff --git a/src/routes/_actions/accounts.js b/src/routes/_actions/accounts.js index 82e815bd..f9c50402 100644 --- a/src/routes/_actions/accounts.js +++ b/src/routes/_actions/accounts.js @@ -7,17 +7,6 @@ async function _updateAccount (accountId, instanceName, accessToken) { const localPromise = database.getAccount(instanceName, accountId) const remotePromise = getAccount(instanceName, accessToken, accountId).then(account => { /* no await */ database.setAccount(instanceName, account) - if (process.browser) { - var countMax = 0; - const _this = setInterval(function() { - if (countMax >= 100 || window.fediloveData !== undefined) { - // save the current shown account so we can use it on fedilove.js - window.fediloveData.currentAccount = account; - return clearInterval(_this); - } - countMax++; - }, 100); - } return account }) diff --git a/src/routes/_actions/timeline.js b/src/routes/_actions/timeline.js index dc66c92c..eb9d7581 100644 --- a/src/routes/_actions/timeline.js +++ b/src/routes/_actions/timeline.js @@ -217,10 +217,6 @@ export async function setupTimeline () { currentTimeline } = store.get() console.log({ timelineItemSummaries, timelineItemSummariesAreStale, currentTimeline }) - if (currentTimeline.startsWith('account/') && - timelineItemSummaries !== null && timelineItemSummaries.length === 0) { - setTimeout(function() { window.fediloveData.currentAccountIsEmpty = true }, 250); - } if (!timelineItemSummaries || timelineItemSummariesAreStale || currentTimeline.startsWith('status/')) { diff --git a/src/routes/_api/timelines.js b/src/routes/_api/timelines.js index 4fc24c42..8495e570 100644 --- a/src/routes/_api/timelines.js +++ b/src/routes/_api/timelines.js @@ -85,10 +85,6 @@ export async function getTimeline (instanceName, accessToken, timeline, maxId, s if (timeline === 'federated') { items = window.fediloveFunctions.filterItemsForFedilove(items); - } else if (timeline.startsWith('account/') && params.tagged === 'fediloveimg') { - if (items.length === 0) { - window.fediloveData.currentAccountIsEmpty = true; - } } return { items, headers } diff --git a/src/scss/themes/ozark.scss b/src/scss/themes/ozark.scss index 2d4f16b4..ea0eafc7 100644 --- a/src/scss/themes/ozark.scss +++ b/src/scss/themes/ozark.scss @@ -556,12 +556,30 @@ div.main-content.meet { max-width: 90em; margin: auto; } + + div#noone-to-meet { + position: fixed; + top: 0; + color: #fff; + width: 100vw; + height: 100vh; + display: flex; + span { + margin: auto; + font-weight: bold; + font-size: 1.5em; + } + } } div.infinite-scroll-page { background: transparent !important; } + div.virtual-list-item.meetnotshown { + display: none !important; + } + div.virtual-list-item.meetshown { z-index: 20 !important; width: 100% !important; diff --git a/static/fedilove-no-react.js b/static/fedilove-no-react.js index 23d5c269..5db4106f 100644 --- a/static/fedilove-no-react.js +++ b/static/fedilove-no-react.js @@ -175,11 +175,12 @@ var fediloveUI = { }, meetPageGoToCurrentAccount: function(isRightSwipe) { isRightSwipe = isRightSwipe || false; - const elements = $('div.virtual-list > div.virtual-list-item > article'); - if (!isRightSwipe && elements.length > 0) { - const accId = elements.first().data('account'); - elements.first()[0].style.animation = 'dismissMeet .25s linear 1'; - setTimeout(function() { fediloveApi.redirect(`/accounts/${accId}`) }, 200); + const accObj = fediloveApi.getMeetAccount(); + if (!isRightSwipe && accObj !== undefined) { + const elem2Anim = $('div.virtual-list > div.virtual-list-item.meetshown:visible')[0]; + if (elem2Anim !== undefined) + elem2Anim.style.animation = 'dismissMeet .25s linear 1'; + setTimeout(function() { fediloveApi.redirect(`/accounts/${accObj.id}`) }, 200); } }, scrollChatToLastItem: function() { @@ -603,7 +604,7 @@ function fedilove_customization() { } clearInterval(_this); - } else if (fediloveData.currentAccountIsEmpty) { + } else if ($('div.virtual-list > div.nothing-to-show').length === 1) { if ($('div.virtual-list > div.no-images-account').length === 0) $('div.virtual-list').append('
'); _applyImageTo('div.virtual-list > div.no-images-account > img.fixed-size-img'); @@ -635,17 +636,30 @@ function fedilove_customization() { fediloveUI.meetPageGoToCurrentAccount(swiperightBol) }); - // remove discarded accounts from timeline (temporal, if /federated is reloaded, blocked accounts won't show either) - for (var accId of fediloveData.tmpDiscardedAccounts) - $('article[data-account='+accId+']').parent().remove(); - // make sure only the wanted items in timeline are shown + var prevItems; + var itemsDrawnOnce = false; const _this = setInterval(function() { if (window.location.pathname !== '/federated') return clearInterval(_this); - const items = $('div.virtual-list > div.virtual-list-item'); + if ($('div#noone-to-meet').length === 0) + $('div.timeline').parent().append(''); + + // remove discarded accounts from timeline (temporal, + // if /federated is reloaded, blocked accounts won't show either) + prevItems = $('div.virtual-list > div.virtual-list-item:visible'); + + for (var accId of fediloveData.tmpDiscardedAccounts) { + $('article[data-account='+accId+']').each(function() { + $(this).parent().addClass('meetnotshown'); + if ($(this)[0].id === window.fediloveData.currentIDMeetTimeline) + window.fediloveData.currentIDMeetTimeline = null; + }); + } + + const items = $('div.virtual-list > div.virtual-list-item:visible'); if (items.length > 0) { if (window.fediloveData.currentIDMeetTimeline === null || document.getElementById(window.fediloveData.currentIDMeetTimeline) === null) { @@ -660,8 +674,13 @@ function fedilove_customization() { if (itemToId.length > 0) itemToId.parent().addClass('meetshown'); } + } else { + if (prevItems.length != items.length && $('div#noone-to-meet').length > 0) + $('div#noone-to-meet')[0].style = ''; } + prevItems = items; + }, 200); } else if (window.location.pathname.startsWith('/notifications/mentions')) {