Trying implementations of the "Nope" feature on Meet account
* Nope is implemented by blocking the account, as by doing so, it won't appear anymore * However, accounts will be silenced as soon as a message comes from someone that did not match both parties
This commit is contained in:
parent
4291d4e442
commit
2b9c2424fe
|
@ -36,7 +36,7 @@
|
||||||
<div class="like-div"><a class="status-favs-reblogs status-favs"
|
<div class="like-div"><a class="status-favs-reblogs status-favs"
|
||||||
rel="prefetch"
|
rel="prefetch"
|
||||||
href="javascript:void(0)"
|
href="javascript:void(0)"
|
||||||
onclick="return api_status_fav(this,'{originalStatusId}');"
|
onclick="return fediloveMastodon.API.statusFav(this,'{originalStatusId}');"
|
||||||
aria-label={favoritesLabel}>
|
aria-label={favoritesLabel}>
|
||||||
<svg class="status-favs-reblogs-svg"><path d="M12,21.35L10.55,20.03C5.4,15.36 2,12.27 2,8.5C2,5.41 4.42,3 7.5,3C9.24,3 10.91,3.81 12,5.08C13.09,3.81 14.76,3 16.5,3C19.58,3 22,5.41 22,8.5C22,12.27 18.6,15.36 13.45,20.03L12,21.35Z"></path></svg>
|
<svg class="status-favs-reblogs-svg"><path d="M12,21.35L10.55,20.03C5.4,15.36 2,12.27 2,8.5C2,5.41 4.42,3 7.5,3C9.24,3 10.91,3.81 12,5.08C13.09,3.81 14.76,3 16.5,3C19.58,3 22,5.41 22,8.5C22,12.27 18.6,15.36 13.45,20.03L12,21.35Z"></path></svg>
|
||||||
<span>{numFavs}</span>
|
<span>{numFavs}</span>
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
<textarea type="text" placeholder="Send your message"></textarea>
|
<textarea type="text" placeholder="Send your message"></textarea>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<button id="send" onclick="return api_send_message();" class="primary compose-box-button" aria-label="Send!">
|
<button id="send" onclick="return fediloveMastodon.API.sendMessage();" class="primary compose-box-button" aria-label="Send!">
|
||||||
<svg xlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" height="24" width="24">
|
<svg xlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" height="24" width="24">
|
||||||
<path d="M0 0h24v24H0z" fill="none"/><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/>
|
<path d="M0 0h24v24H0z" fill="none"/><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
|
@ -5,33 +5,37 @@
|
||||||
|
|
||||||
// Do simple XHR requests to the API on Mastodon
|
// Do simple XHR requests to the API on Mastodon
|
||||||
// make sure you control errors correctly, as a Mastodon Server might not setup CORS correctly
|
// make sure you control errors correctly, as a Mastodon Server might not setup CORS correctly
|
||||||
function mastodon_get(path, payload, callbk) { return mastodon_request('GET', path, payload, callbk); }
|
const fediloveMastodon = {
|
||||||
function mastodon_post(path, payload, callbk) { return mastodon_request('POST', path, payload, callbk); }
|
request: function(method, path, payload, callbk) {
|
||||||
function mastodon_request(method, path, payload, callbk) {
|
|
||||||
payload = payload || null;
|
payload = payload || null;
|
||||||
|
|
||||||
const ACCESS_TOKEN = window.fediloveApi.getAccessToken();
|
const ACCESS_TOKEN = window.fediloveApi.getAccessToken();
|
||||||
if (ACCESS_TOKEN === undefined)
|
if (ACCESS_TOKEN === undefined)
|
||||||
return callbk(undefined);
|
return callbk(undefined);
|
||||||
|
|
||||||
const API_URL = 'https://'+fediloveApi.getCurrentInstance()+path;
|
const API_URL = 'https://'+fediloveApi.getCurrentInstance()+path;
|
||||||
|
|
||||||
const oReq = new XMLHttpRequest();
|
const oReq = new XMLHttpRequest();
|
||||||
oReq.addEventListener("load", function() { callbk(this.responseText); });
|
oReq.addEventListener("load", function() { callbk(this.responseText); });
|
||||||
oReq.open(method, API_URL);
|
oReq.open(method, API_URL);
|
||||||
oReq.setRequestHeader('Authorization', 'Bearer '+ACCESS_TOKEN);
|
oReq.setRequestHeader('Authorization', 'Bearer '+ACCESS_TOKEN);
|
||||||
oReq.send(payload);
|
oReq.send(payload);
|
||||||
}
|
},
|
||||||
|
get: function(path, payload, callbk) {
|
||||||
function api_status_fav(dom, status_id) {
|
return fediloveMastodon.request('GET', path, payload, callbk);
|
||||||
|
},
|
||||||
|
post: function(path, payload, callbk) {
|
||||||
|
return fediloveMastodon.request('POST', path, payload, callbk);
|
||||||
|
},
|
||||||
|
API: {
|
||||||
|
discardAccount: function(account_id, cback) {
|
||||||
|
fediloveMastodon.post('/api/v1/accounts/18084/block', {}, function(data) { cback() });
|
||||||
|
},
|
||||||
|
statusFav: function(dom, status_id) {
|
||||||
var dislike = false;
|
var dislike = false;
|
||||||
var path = `/api/v1/statuses/${status_id}/favourite`;
|
var path = `/api/v1/statuses/${status_id}/favourite`;
|
||||||
if (dom.getAttribute('data-liked') === "1") {
|
if (dom.getAttribute('data-liked') === "1") {
|
||||||
path = `/api/v1/statuses/${status_id}/unfavourite`;
|
path = `/api/v1/statuses/${status_id}/unfavourite`;
|
||||||
dislike = true;
|
dislike = true;
|
||||||
}
|
}
|
||||||
mastodon_post(path, {}, function(data) {
|
fediloveMastodon.post(path, {}, function(data) {
|
||||||
// to-do: check "data" if the POST succeded (for now we expect it did xD)
|
|
||||||
if (!dislike) {
|
if (!dislike) {
|
||||||
$(dom).addClass('liked-msg');
|
$(dom).addClass('liked-msg');
|
||||||
$(dom).attr('data-liked', 1);
|
$(dom).attr('data-liked', 1);
|
||||||
|
@ -43,12 +47,8 @@ function api_status_fav(dom, status_id) {
|
||||||
dom.style.animation = undefined;
|
dom.style.animation = undefined;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
sendMessage: function() {
|
||||||
// The api to send a message on the current chat thread has been improved a lot
|
|
||||||
// and now is much more rock-solid, and we reuse the React functions
|
|
||||||
function api_send_message() {
|
|
||||||
|
|
||||||
// the message is composed from the current chat Acct (@user@domain) + the compose textarea value
|
// the message is composed from the current chat Acct (@user@domain) + the compose textarea value
|
||||||
const text = fediloveData.chatAvatarCache.acct + ' ' + $('div#chat-compose-global textarea').val();
|
const text = fediloveData.chatAvatarCache.acct + ' ' + $('div#chat-compose-global textarea').val();
|
||||||
|
|
||||||
|
@ -63,6 +63,8 @@ function api_send_message() {
|
||||||
// scroll to the end as all chat Apps do
|
// scroll to the end as all chat Apps do
|
||||||
fediloveUI.scrollChatToLastItem();
|
fediloveUI.scrollChatToLastItem();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var fediloveUI = {
|
var fediloveUI = {
|
||||||
registerSwipeOnElementEvents: {
|
registerSwipeOnElementEvents: {
|
||||||
|
@ -219,7 +221,16 @@ var fediloveUI = {
|
||||||
$('div#chat-party-global > div#name > span').text(acct);
|
$('div#chat-party-global > div#name > span').text(acct);
|
||||||
if (accid != 0) $('div#chat-party-global > div#name > a').attr('href', `/accounts/${accid}`);
|
if (accid != 0) $('div#chat-party-global > div#name > a').attr('href', `/accounts/${accid}`);
|
||||||
},
|
},
|
||||||
onAccountNope: function() {},
|
onAccountNope: function() {
|
||||||
|
const accObj = fediloveApi.getMeetAccount();
|
||||||
|
if (accObj === undefined) return;
|
||||||
|
if (!fediloveData.tmpDiscardedAccounts.includes(accObj.id))
|
||||||
|
fediloveData.tmpDiscardedAccounts.push(accObj.id);
|
||||||
|
fediloveMastodon.API.discardAccount(accObj.id, function() {
|
||||||
|
$('div.virtual-list')[0].style.animation = 'nopeMeet .25s linear 1';
|
||||||
|
setTimeout(function() { window.history.back() }, 220);
|
||||||
|
});
|
||||||
|
},
|
||||||
onAccountMatch: function() {},
|
onAccountMatch: function() {},
|
||||||
onAccountMaybe: function() {}
|
onAccountMaybe: function() {}
|
||||||
};
|
};
|
||||||
|
@ -301,6 +312,7 @@ var fediloveData = {
|
||||||
myAccountId: undefined,
|
myAccountId: undefined,
|
||||||
currentAccountIsEmpty: false,
|
currentAccountIsEmpty: false,
|
||||||
currentIDMeetTimeline: null,
|
currentIDMeetTimeline: null,
|
||||||
|
tmpDiscardedAccounts: [],
|
||||||
gotEmojifyTextFunction: false,
|
gotEmojifyTextFunction: false,
|
||||||
composeTxtKeypressEvent: false
|
composeTxtKeypressEvent: false
|
||||||
};
|
};
|
||||||
|
@ -338,7 +350,7 @@ var fediloveEvents = {
|
||||||
account_id = data.mentions[0].id;
|
account_id = data.mentions[0].id;
|
||||||
}
|
}
|
||||||
if (account_id === null || account_id === undefined) return;
|
if (account_id === null || account_id === undefined) return;
|
||||||
mastodon_get(`/api/v1/accounts/${account_id}`, {}, function(newData) {
|
fediloveMastodon.get(`/api/v1/accounts/${account_id}`, {}, function(newData) {
|
||||||
var json = JSON.parse(newData);
|
var json = JSON.parse(newData);
|
||||||
if (json !== undefined) {
|
if (json !== undefined) {
|
||||||
waitForEmojifyAndDo( account_id, `@${json.acct}`, json.avatar, json.display_name, json.emojis );
|
waitForEmojifyAndDo( account_id, `@${json.acct}`, json.avatar, json.display_name, json.emojis );
|
||||||
|
@ -385,7 +397,7 @@ function fedilove_customization() {
|
||||||
// get the userAccountId to check against the href /account/NUM on the messages
|
// get the userAccountId to check against the href /account/NUM on the messages
|
||||||
// so we can apply different style to my messages
|
// so we can apply different style to my messages
|
||||||
if (fediloveData.myAccountId === undefined) {
|
if (fediloveData.myAccountId === undefined) {
|
||||||
mastodon_get('/api/v1/accounts/verify_credentials', {}, function(data) {
|
fediloveMastodon.get('/api/v1/accounts/verify_credentials', {}, function(data) {
|
||||||
const json = JSON.parse(data);
|
const json = JSON.parse(data);
|
||||||
if (json !== undefined) {
|
if (json !== undefined) {
|
||||||
fediloveData.myAccountId = json.id;
|
fediloveData.myAccountId = json.id;
|
||||||
|
@ -432,6 +444,10 @@ function fedilove_customization() {
|
||||||
0% {position: relative; left: 0}
|
0% {position: relative; left: 0}
|
||||||
100% {position: relative; left: 95%}
|
100% {position: relative; left: 95%}
|
||||||
}
|
}
|
||||||
|
@keyframes nopeMeet {
|
||||||
|
0% {position: relative; top: 0}
|
||||||
|
100% {position: relative; top: 95vh}
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
document.body.appendChild(style);
|
document.body.appendChild(style);
|
||||||
}
|
}
|
||||||
|
@ -619,6 +635,10 @@ function fedilove_customization() {
|
||||||
fediloveUI.meetPageGoToCurrentAccount(swiperightBol)
|
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
|
// make sure only the wanted items in timeline are shown
|
||||||
const _this = setInterval(function()
|
const _this = setInterval(function()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue