FIX: instantly removes group message when leaving (#25961)

Prior to this fix clicking <kbd>x</kdb> on a channel row would effectively leave the channel on server side, but it wouldn't disappear from the screen before a page refresh.
This commit is contained in:
Joffrey JAFFEUX
2024-02-29 23:49:01 +01:00
committed by GitHub
parent 40eea40d69
commit 0b778697ff
5 changed files with 123 additions and 11 deletions

View File

@ -322,8 +322,14 @@ export default class ChatApi extends Service {
* @param {number} channelId - The ID of the channel.
* @returns {Promise}
*/
leaveChannel(channelId) {
return this.#deleteRequest(`/channels/${channelId}/memberships/me`);
async leaveChannel(channelId) {
await this.#deleteRequest(`/channels/${channelId}/memberships/me`);
const channel = await this.chatChannelsManager.find(channelId, {
fetchIfNotFound: false,
});
if (channel) {
this.chatChannelsManager.remove(channel);
}
}
/**