Show hidden friend requests

This commit is contained in:
Natsumi
2021-08-10 17:01:57 +12:00
parent 6cab3a1e94
commit 0bcee52851
2 changed files with 87 additions and 11 deletions

View File

@@ -1675,7 +1675,8 @@ speechSynthesis.getVoices();
}).then((json) => {
var args = {
json,
params
params,
option
};
this.$emit('WORLD:LIST', args);
return args;
@@ -1916,6 +1917,21 @@ speechSynthesis.getVoices();
});
};
API.deleteHiddenFriendRequest = function (params, userId) {
return this.call(`user/${userId}/friendRequest`, {
method: 'DELETE',
params
}).then((json) => {
var args = {
json,
params,
userId
};
this.$emit('NOTIFICATION:HIDE', args);
return args;
});
};
/*
params: {
userId: string
@@ -2158,6 +2174,18 @@ speechSynthesis.getVoices();
}
});
API.$on('NOTIFICATION:LIST:HIDDEN', function (args) {
for (var json of args.json) {
json.type = 'hiddenFriendRequest';
this.$emit('NOTIFICATION', {
json,
params: {
notificationId: json.id
}
});
}
});
API.$on('NOTIFICATION:ACCEPT', function (args) {
var ref = this.cachedNotifications.get(args.params.notificationId);
if (typeof ref === 'undefined' ||
@@ -2237,6 +2265,9 @@ speechSynthesis.getVoices();
API.expireNotifications = function () {
for (var ref of this.cachedNotifications.values()) {
ref.$isExpired = true;
if ((ref.type === 'friendRequest') || (ref.type === 'hiddenFriendRequest')) {
this.cachedNotifications.delete(ref.id);
}
}
};
@@ -2272,6 +2303,19 @@ speechSynthesis.getVoices();
break;
}
}
var params = {
n: 100,
offset: 0
};
var count = 50; //5000 max
for (var i = 0; i < count; i++) {
var args = await this.getHiddenFriendRequests(params);
$app.unseenNotifications = [];
params.offset += 100;
if (args.json.length < 100) {
break;
}
}
this.deleteExpiredNotifcations();
this.isNotificationsLoading = false;
};
@@ -2299,6 +2343,24 @@ speechSynthesis.getVoices();
});
};
API.getHiddenFriendRequests = function (params) {
return this.call('auth/user/notifications', {
method: 'GET',
params: {
type: 'friendRequest',
hidden: true,
...params
}
}).then((json) => {
var args = {
json,
params
};
this.$emit('NOTIFICATION:LIST:HIDDEN', args);
return args;
});
};
API.clearNotifications = function () {
return this.call('auth/user/notifications/clear', {
method: 'PUT'
@@ -2329,7 +2391,8 @@ speechSynthesis.getVoices();
}).then((json) => {
var args = {
json,
params
params,
receiverUserId
};
this.$emit('NOTIFICATION:INVITE:SEND', args);
return args;
@@ -2344,7 +2407,8 @@ speechSynthesis.getVoices();
}).then((json) => {
var args = {
json,
params
params,
receiverUserId
};
this.$emit('NOTIFICATION:INVITE:PHOTO:SEND', args);
return args;
@@ -2358,7 +2422,8 @@ speechSynthesis.getVoices();
}).then((json) => {
var args = {
json,
params
params,
receiverUserId
};
this.$emit('NOTIFICATION:REQUESTINVITE:SEND', args);
return args;
@@ -2373,7 +2438,8 @@ speechSynthesis.getVoices();
}).then((json) => {
var args = {
json,
params
params,
receiverUserId
};
this.$emit('NOTIFICATION:REQUESTINVITE:PHOTO:SEND', args);
return args;
@@ -7558,9 +7624,17 @@ speechSynthesis.getVoices();
type: 'info',
callback: (action) => {
if (action === 'confirm') {
API.hideNotification({
notificationId: row.id
});
if (row.type === 'hiddenFriendRequest') {
API.deleteHiddenFriendRequest({
notificationId: row.id
},
row.senderUserId
);
} else {
API.hideNotification({
notificationId: row.id
});
}
}
}
});
@@ -11512,7 +11586,8 @@ speechSynthesis.getVoices();
}).then((json) => {
var args = {
json,
params
params,
fileId
};
this.$emit('AVATARIMAGE:INIT', args);
return args;
@@ -11816,7 +11891,8 @@ speechSynthesis.getVoices();
}).then((json) => {
var args = {
json,
params
params,
fileId
};
this.$emit('WORLDIMAGE:INIT', args);
return args;

View File

@@ -431,7 +431,7 @@ html
template(#tool)
div(style="margin:0 0 10px;display:flex;align-items:center")
el-select(v-model="notificationTable.filters[0].value" multiple clearable collapse-tags style="flex:1" placeholder="Filter")
el-option(v-once v-for="type in ['requestInvite', 'invite', 'requestInviteResponse', 'inviteResponse', 'friendRequest', 'message']" :key="type" :label="type" :value="type")
el-option(v-once v-for="type in ['requestInvite', 'invite', 'requestInviteResponse', 'inviteResponse', 'friendRequest', 'hiddenFriendRequest', 'message']" :key="type" :label="type" :value="type")
el-input(v-model="notificationTable.filters[1].value" placeholder="Search" style="flex:none;width:150px;margin:0 10px")
el-tooltip(placement="bottom" content="Refresh" :disabled="hideTooltips")
el-button(type="default" :loading="API.isNotificationsLoading" @click="API.refreshNotifications()" icon="el-icon-refresh" circle style="flex:none")