Skip to content

Commit

Permalink
fix: Handle 404 error when accepting friend request notification (vrc…
Browse files Browse the repository at this point in the history
  • Loading branch information
Map1en authored Dec 16, 2024
1 parent 109753b commit 8f68422
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
31 changes: 19 additions & 12 deletions html/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2392,20 +2392,27 @@ speechSynthesis.getVoices();
* @param {{ notificationId: string }} params
* @return { Promise<{json: any, params}> }
*/
API.acceptNotification = function (params) {
API.acceptFriendRequestNotification = function (params) {
return this.call(
`auth/user/notifications/${params.notificationId}/accept`,
{
method: 'PUT'
}
).then((json) => {
var args = {
json,
params
};
this.$emit('NOTIFICATION:ACCEPT', args);
return args;
});
)
.then((json) => {
var args = {
json,
params
};
this.$emit('NOTIFICATION:ACCEPT', args);
return args;
})
.catch((err) => {
// if friend request could not be found, delete it
if (err && err.message && err.message.includes('404')) {
this.$emit('NOTIFICATION:HIDE', { params });
}
});
};

/**
Expand Down Expand Up @@ -7526,15 +7533,15 @@ speechSynthesis.getVoices();
}
});

$app.methods.acceptNotification = function (row) {
$app.methods.acceptFriendRequestNotification = function (row) {
// FIXME: 메시지 수정
this.$confirm('Continue? Accept Friend Request', 'Confirm', {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
type: 'info',
callback: (action) => {
if (action === 'confirm') {
API.acceptNotification({
API.acceptFriendRequestNotification({
notificationId: row.id
});
}
Expand Down Expand Up @@ -10601,7 +10608,7 @@ speechSynthesis.getVoices();
userId
});
} else {
API.acceptNotification({
API.acceptFriendRequestNotification({
notificationId: key
});
}
Expand Down
2 changes: 1 addition & 1 deletion html/src/mixins/tabs/notifications.pug
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ mixin notificationsTab()
template(v-if="scope.row.senderUserId !== API.currentUser.id && !scope.row.$isExpired")
template(v-if="scope.row.type === 'friendRequest'")
el-tooltip(placement="top" content="Accept" :disabled="hideTooltips")
el-button(type="text" icon="el-icon-check" size="mini" @click="acceptNotification(scope.row)")
el-button(type="text" icon="el-icon-check" size="mini" @click="acceptFriendRequestNotification(scope.row)")
template(v-else-if="scope.row.type === 'invite'")
el-tooltip(placement="top" content="Decline with message" :disabled="hideTooltips")
el-button(type="text" icon="el-icon-chat-line-square" size="mini" @click="showSendInviteResponseDialog(scope.row)")
Expand Down

0 comments on commit 8f68422

Please sign in to comment.