guard against deleting the last chat
This commit is contained in:
parent
8075585778
commit
d95152efe2
|
@ -11,7 +11,8 @@
|
||||||
function delChat (chatId) {
|
function delChat (chatId) {
|
||||||
if (activeChatId === chatId) {
|
if (activeChatId === chatId) {
|
||||||
// switch to another chat if deleting the active one
|
// switch to another chat if deleting the active one
|
||||||
const newChatId = _.maxBy($chatsStorage.filter(chat => chat.id !== chatId), 'id').id
|
const newChatId = _.maxBy($chatsStorage.filter(chat => chat.id !== chatId), 'id')?.id
|
||||||
|
if (!newChatId) return
|
||||||
replace(`/chat/:${newChatId}`).then(() => deleteChat(chatId))
|
replace(`/chat/:${newChatId}`).then(() => deleteChat(chatId))
|
||||||
} else {
|
} else {
|
||||||
deleteChat(chatId)
|
deleteChat(chatId)
|
||||||
|
|
Loading…
Reference in New Issue