Implemented "Maybe" feature. Ignores account for 24 hours (localStorage)
* I wanted to add a Maybe feature, so it won't show us an account for 24 hours in case we are not sure of someone, and want to give him/her another chance * Little fixed and improvements
This commit is contained in:
parent
0a9d739269
commit
8d2194af4b
|
@ -268,14 +268,17 @@ var fediloveUI = {
|
||||||
countMax++;
|
countMax++;
|
||||||
}, 100);
|
}, 100);
|
||||||
},
|
},
|
||||||
|
animateMainContentSwipe: function(animName, cback) {
|
||||||
|
$('div.virtual-list')[0].style.animation = `${animName} .25s linear 1`;
|
||||||
|
setTimeout(cback, 220);
|
||||||
|
},
|
||||||
onAccountNope: function() {
|
onAccountNope: function() {
|
||||||
const accObj = fediloveApi.getMeetAccount();
|
const accObj = fediloveApi.getMeetAccount();
|
||||||
if (accObj === undefined) return;
|
if (accObj === undefined) return;
|
||||||
if (!fediloveData.tmpDiscardedAccounts.includes(accObj.id))
|
if (!fediloveData.tmpDiscardedAccounts.includes(accObj.id))
|
||||||
fediloveData.tmpDiscardedAccounts.push(accObj.id);
|
fediloveData.tmpDiscardedAccounts.push(accObj.id);
|
||||||
fediloveMastodon.API.discardAccount(accObj.id, function() {
|
fediloveMastodon.API.discardAccount(accObj.id, function() {
|
||||||
$('div.virtual-list')[0].style.animation = 'nopeMeet .25s linear 1';
|
fediloveUI.animateMainContentSwipe('nopeMeet', function() { window.history.back() });
|
||||||
setTimeout(function() { window.history.back() }, 220);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onAccountMatch: function() {
|
onAccountMatch: function() {
|
||||||
|
@ -284,11 +287,22 @@ var fediloveUI = {
|
||||||
if (fediloveData.meetRelationships[accObj.id] !== undefined)
|
if (fediloveData.meetRelationships[accObj.id] !== undefined)
|
||||||
fediloveData.meetRelationships[accObj.id] = { 'id': accObj.id, 'requested': true }
|
fediloveData.meetRelationships[accObj.id] = { 'id': accObj.id, 'requested': true }
|
||||||
fediloveMastodon.API.matchAccount(accObj.id, function() {
|
fediloveMastodon.API.matchAccount(accObj.id, function() {
|
||||||
$('div.virtual-list')[0].style.animation = 'yepMeet .25s linear 1';
|
fediloveUI.animateMainContentSwipe('yepMeet', function() { window.history.back() });
|
||||||
setTimeout(function() { window.history.back() }, 220);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onAccountMaybe: function() {}
|
onAccountMaybe: function() {
|
||||||
|
const accObj = fediloveApi.getMeetAccount();
|
||||||
|
if (accObj === undefined) return;
|
||||||
|
|
||||||
|
const expire = 24 * (60*60*1000); // hours. Expire the maybe after 24 hours
|
||||||
|
var accounts = {};
|
||||||
|
if (window.localStorage.store_maybeAccounts !== undefined)
|
||||||
|
accounts = JSON.parse(window.localStorage.store_maybeAccounts);
|
||||||
|
accounts[accObj.id] = Date.now() + expire;
|
||||||
|
window.localStorage.store_maybeAccounts = JSON.stringify(accounts);
|
||||||
|
|
||||||
|
fediloveUI.animateMainContentSwipe('acceptMeet', function() { window.history.back() });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// objects to access from React code
|
// objects to access from React code
|
||||||
|
@ -459,16 +473,8 @@ function fedilove_customization() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the userAccountId to check against the href /account/NUM on the messages
|
if (fediloveData.myAccountId === undefined && window.__store.get().verifyCredentials !== undefined)
|
||||||
// so we can apply different style to my messages
|
fediloveData.myAccountId = window.__store.get().verifyCredentials[fediloveApi.getCurrentInstance()].id;
|
||||||
if (fediloveData.myAccountId === undefined) {
|
|
||||||
fediloveMastodon.get('/api/v1/accounts/verify_credentials', {}, function(data) {
|
|
||||||
const json = JSON.parse(data);
|
|
||||||
if (json !== undefined) {
|
|
||||||
fediloveData.myAccountId = json.id;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (document.querySelector('#main-nav > div#dummy-nav') != null) {
|
if (document.querySelector('#main-nav > div#dummy-nav') != null) {
|
||||||
document.querySelector('#main-nav > div#dummy-nav').remove();
|
document.querySelector('#main-nav > div#dummy-nav').remove();
|
||||||
|
@ -715,6 +721,12 @@ function fedilove_customization() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// "maybe" Accounts are stored on localStorage
|
||||||
|
// as there is no way to save this on Mastodon
|
||||||
|
const nowDate = Date.now();
|
||||||
|
const maybeAccounts = localStorage.store_maybeAccounts !== undefined ?
|
||||||
|
JSON.parse(localStorage.store_maybeAccounts) : [];
|
||||||
|
|
||||||
// make sure only the wanted items in timeline are shown
|
// make sure only the wanted items in timeline are shown
|
||||||
var prevItems;
|
var prevItems;
|
||||||
var itemsDrawnOnce = false;
|
var itemsDrawnOnce = false;
|
||||||
|
@ -726,6 +738,7 @@ function fedilove_customization() {
|
||||||
if (!fediloveData.meetRelationshipsFilled)
|
if (!fediloveData.meetRelationshipsFilled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// added when there is no more profiles to Meet
|
||||||
if ($('div#noone-to-meet').length === 0)
|
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>');
|
$('div.timeline').parent().append('<div id="noone-to-meet" style="display: none"><span>Nothing to show</span></div>');
|
||||||
|
|
||||||
|
@ -738,12 +751,18 @@ function fedilove_customization() {
|
||||||
for (var accId of fediloveData.tmpDiscardedAccounts)
|
for (var accId of fediloveData.tmpDiscardedAccounts)
|
||||||
_discardAccountUI(accId);
|
_discardAccountUI(accId);
|
||||||
|
|
||||||
|
// discard localStorage powered maybe accounts (by "Maybe" action)
|
||||||
|
for (var accId of Object.keys(maybeAccounts))
|
||||||
|
if (maybeAccounts[accId] !== undefined && maybeAccounts[accId] > nowDate)
|
||||||
|
_discardAccountUI(accId);
|
||||||
|
|
||||||
// discard the ones we "matched" (by "Match" action
|
// discard the ones we "matched" (by "Match" action
|
||||||
for (var accId of Object.keys(fediloveData.meetRelationships))
|
for (var accId of Object.keys(fediloveData.meetRelationships))
|
||||||
if (fediloveData.meetRelationships[accId].requested)
|
if (fediloveData.meetRelationships[accId].requested)
|
||||||
_discardAccountUI(accId);
|
_discardAccountUI(accId);
|
||||||
|
|
||||||
|
|
||||||
|
// paint the current Meet account, after adding classes to hide what we want
|
||||||
const items = $('div.virtual-list > div.virtual-list-item:visible');
|
const items = $('div.virtual-list > div.virtual-list-item:visible');
|
||||||
if (items.length > 0) {
|
if (items.length > 0) {
|
||||||
if (window.fediloveData.currentIDMeetTimeline === null ||
|
if (window.fediloveData.currentIDMeetTimeline === null ||
|
||||||
|
|
Loading…
Reference in New Issue