feat: focus the previous/next message when one is deleted. If 0 messages, focus input
This commit is contained in:
@@ -54,6 +54,7 @@ export const API = {
|
||||
|
||||
async getMessages(channelId: string) {
|
||||
const response = await API.request("GET", `channels/${channelId}/messages`);
|
||||
console.log(response)
|
||||
const json = await response.json();
|
||||
return json.messages as IMessage[];
|
||||
},
|
||||
|
@@ -44,6 +44,7 @@ export class List extends UINode {
|
||||
if (idx === this.focused) {
|
||||
if (this.focused > 0) this.focused--;
|
||||
this.calculateTabIndex();
|
||||
this.children[this.focused].focus()
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@@ -231,7 +231,9 @@ export class MainView extends View {
|
||||
itm.onKeyDown((key: string, alt: boolean | undefined, shift: boolean | undefined, ctrl: boolean | undefined) => {
|
||||
if (key === "Delete") {
|
||||
this.removeMessage(message.id);
|
||||
this.messageInput.focus()
|
||||
if (this.messageList.children.length === 1) {
|
||||
this.messageInput.focus()
|
||||
}
|
||||
}
|
||||
});
|
||||
return itm;
|
||||
|
Reference in New Issue
Block a user