Implementing account relationships control on Meet Timeline
* Fill relationships of all current statuses to fediloveData * Added match discarding featire on Meet timeline (not working 100% OK yet)
This commit is contained in:
parent
55c4ec5ee1
commit
9deba874e1
|
@ -273,3 +273,7 @@ export async function showMoreItemsForThread (instanceName, timelineName) {
|
|||
})
|
||||
stop('showMoreItemsForThread')
|
||||
}
|
||||
|
||||
if (process.browser) {
|
||||
window.__database = database;
|
||||
}
|
||||
|
|
|
@ -227,6 +227,32 @@ var fediloveUI = {
|
|||
$('div#chat-party-global > div#name > span').text(acct);
|
||||
if (accid != 0) $('div#chat-party-global > div#name > a').attr('href', `/accounts/${accid}`);
|
||||
},
|
||||
fillMeetRelationships: function() {
|
||||
var countMax = 0;
|
||||
const _this = setInterval(function() {
|
||||
if (countMax > 100) {
|
||||
return clearInterval(_this);
|
||||
}
|
||||
const items = window.__store.get().timelineItemSummaries;
|
||||
if (items !== null && items.length > 0) {
|
||||
var refIds = [];
|
||||
for (var it of items) {
|
||||
if (!refIds.includes(it.accountId))
|
||||
refIds.push(it.accountId);
|
||||
}
|
||||
for (var accId of refIds) {
|
||||
window.__database.getRelationship(fediloveApi.getCurrentInstance(), accId+"").then(function(rel) {
|
||||
if (rel !== undefined && fediloveData.meetRelationships[rel.id] === undefined)
|
||||
fediloveData.meetRelationships[rel.id] = rel;
|
||||
if (Object.keys(window.fediloveData.meetRelationships).length === refIds.length)
|
||||
fediloveData.meetRelationshipsFilled = true;
|
||||
});
|
||||
}
|
||||
clearInterval(_this);
|
||||
}
|
||||
countMax++;
|
||||
}, 100);
|
||||
},
|
||||
onAccountNope: function() {
|
||||
const accObj = fediloveApi.getMeetAccount();
|
||||
if (accObj === undefined) return;
|
||||
|
@ -240,8 +266,8 @@ var fediloveUI = {
|
|||
onAccountMatch: function() {
|
||||
const accObj = fediloveApi.getMeetAccount();
|
||||
if (accObj === undefined) return;
|
||||
if (!fediloveData.tmpDiscardedAccounts.includes(accObj.id))
|
||||
fediloveData.tmpDiscardedAccounts.push(accObj.id);
|
||||
if (fediloveData.meetRelationships[accObj.id] !== undefined)
|
||||
fediloveData.meetRelationships[accObj.id] = { 'id': accObj.id, 'requested': true }
|
||||
fediloveMastodon.API.matchAccount(accObj.id, function() {
|
||||
$('div.virtual-list')[0].style.animation = 'yepMeet .25s linear 1';
|
||||
setTimeout(function() { window.history.back() }, 220);
|
||||
|
@ -328,6 +354,8 @@ var fediloveData = {
|
|||
currentAccountIsEmpty: false,
|
||||
currentIDMeetTimeline: null,
|
||||
tmpDiscardedAccounts: [],
|
||||
meetRelationships: {},
|
||||
meetRelationshipsFilled: false,
|
||||
gotEmojifyTextFunction: false,
|
||||
composeTxtKeypressEvent: false
|
||||
};
|
||||
|
@ -650,10 +678,21 @@ function fedilove_customization() {
|
|||
it.attr('style', 'animation: fadeOut .5s linear infinite');
|
||||
}, (i*250), elem);
|
||||
}
|
||||
|
||||
fediloveData.meetRelationshipsFilled = false;
|
||||
fediloveUI.fillMeetRelationships();
|
||||
fediloveUI.registerSwipeOnElement('#meet-navigation #anim-swipe', function(swiperightBol) {
|
||||
fediloveUI.meetPageGoToCurrentAccount(swiperightBol)
|
||||
});
|
||||
|
||||
const _discardAccountUI = function(accId) {
|
||||
$('article[data-account='+accId+']').each(function() {
|
||||
$(this).parent().addClass('meetnotshown');
|
||||
if ($(this)[0].id === fediloveData.currentIDMeetTimeline)
|
||||
fediloveData.currentIDMeetTimeline = null;
|
||||
});
|
||||
};
|
||||
|
||||
// make sure only the wanted items in timeline are shown
|
||||
var prevItems;
|
||||
var itemsDrawnOnce = false;
|
||||
|
@ -662,6 +701,9 @@ function fedilove_customization() {
|
|||
if (window.location.pathname !== '/meet')
|
||||
return clearInterval(_this);
|
||||
|
||||
if (!fediloveData.meetRelationshipsFilled)
|
||||
return;
|
||||
|
||||
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>');
|
||||
|
||||
|
@ -669,13 +711,16 @@ function fedilove_customization() {
|
|||
// if /meet 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;
|
||||
});
|
||||
}
|
||||
|
||||
// discard temporary added accounts (by "Nope" action)
|
||||
for (var accId of fediloveData.tmpDiscardedAccounts)
|
||||
_discardAccountUI(accId);
|
||||
|
||||
// discard the ones we "matched" (by "Match" action
|
||||
for (var accId of Object.keys(fediloveData.meetRelationships))
|
||||
if (fediloveData.meetRelationships[accId].requested)
|
||||
_discardAccountUI(accId);
|
||||
|
||||
|
||||
const items = $('div.virtual-list > div.virtual-list-item:visible');
|
||||
if (items.length > 0) {
|
||||
|
|
Loading…
Reference in New Issue