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
This commit is contained in:
Bofh 2021-01-10 19:34:43 +01:00
parent 2b9c2424fe
commit e897a4c99d
5 changed files with 48 additions and 30 deletions

View File

@ -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
})

View File

@ -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/')) {

View File

@ -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 }

View File

@ -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;

View File

@ -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('<div class="no-images-account"><img class="fixed-size-img"/></div>');
_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('<div id="noone-to-meet" style="display: none"><span>Nothing to show</span></div>');
// 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')) {