Fix add members
This commit is contained in:
parent
74a7f50f70
commit
fa73477a9e
@ -13,11 +13,16 @@ export default class AppAddMembersTab implements SliderTab {
|
|||||||
private peerType: 'channel' | 'chat';
|
private peerType: 'channel' | 'chat';
|
||||||
private peerID: number; // always positive
|
private peerID: number; // always positive
|
||||||
private takeOut: (peerIDs: number[]) => void
|
private takeOut: (peerIDs: number[]) => void
|
||||||
|
private skippable: boolean;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.nextBtn.addEventListener('click', () => {
|
this.nextBtn.addEventListener('click', () => {
|
||||||
let peerIDs = this.selector.getSelected();
|
if(this.skippable) {
|
||||||
|
this.backBtn.click();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const peerIDs = this.selector.getSelected();
|
||||||
if(peerIDs.length) {
|
if(peerIDs.length) {
|
||||||
if(this.takeOut) {
|
if(this.takeOut) {
|
||||||
this.takeOut(peerIDs);
|
this.takeOut(peerIDs);
|
||||||
@ -43,13 +48,14 @@ export default class AppAddMembersTab implements SliderTab {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(id: number, type: 'channel' | 'chat', skipable: boolean, takeOut?: AppAddMembersTab['takeOut']) {
|
public init(id: number, type: 'channel' | 'chat', skippable: boolean, takeOut?: AppAddMembersTab['takeOut']) {
|
||||||
this.peerID = Math.abs(id);
|
this.peerID = Math.abs(id);
|
||||||
this.peerType = type;
|
this.peerType = type;
|
||||||
this.takeOut = takeOut;
|
this.takeOut = takeOut;
|
||||||
|
this.skippable = skippable;
|
||||||
|
|
||||||
this.onCloseAfterTimeout();
|
this.onCloseAfterTimeout();
|
||||||
this.selector = new AppSelectPeers(this.contentDiv, skipable ? null : (length) => {
|
this.selector = new AppSelectPeers(this.contentDiv, skippable ? null : (length) => {
|
||||||
if(length) {
|
if(length) {
|
||||||
this.nextBtn.classList.add('is-visible');
|
this.nextBtn.classList.add('is-visible');
|
||||||
} else {
|
} else {
|
||||||
@ -60,7 +66,7 @@ export default class AppAddMembersTab implements SliderTab {
|
|||||||
this.nextBtn.innerHTML = '';
|
this.nextBtn.innerHTML = '';
|
||||||
this.nextBtn.disabled = false;
|
this.nextBtn.disabled = false;
|
||||||
this.nextBtn.classList.add('tgico-next');
|
this.nextBtn.classList.add('tgico-next');
|
||||||
if(skipable) {
|
if(skippable) {
|
||||||
this.nextBtn.classList.add('is-visible');
|
this.nextBtn.classList.add('is-visible');
|
||||||
} else {
|
} else {
|
||||||
this.nextBtn.classList.remove('is-visible');
|
this.nextBtn.classList.remove('is-visible');
|
||||||
|
@ -13,7 +13,7 @@ export default class AppNewGroupTab implements SliderTab {
|
|||||||
private canvas = this.container.querySelector('.avatar-edit-canvas') as HTMLCanvasElement;
|
private canvas = this.container.querySelector('.avatar-edit-canvas') as HTMLCanvasElement;
|
||||||
private groupNameInput = this.container.querySelector('.new-group-name') as HTMLInputElement;
|
private groupNameInput = this.container.querySelector('.new-group-name') as HTMLInputElement;
|
||||||
private nextBtn = this.container.querySelector('.btn-corner') as HTMLButtonElement;
|
private nextBtn = this.container.querySelector('.btn-corner') as HTMLButtonElement;
|
||||||
private searchGroup = new SearchGroup('', 'contacts', true, 'new-group-members disable-hover', false);
|
private searchGroup = new SearchGroup(' ', 'contacts', true, 'new-group-members disable-hover', false);
|
||||||
private uploadAvatar: () => Promise<any> = null;
|
private uploadAvatar: () => Promise<any> = null;
|
||||||
private userIDs: number[];
|
private userIDs: number[];
|
||||||
|
|
||||||
@ -25,16 +25,12 @@ export default class AppNewGroupTab implements SliderTab {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.groupNameInput.addEventListener('input', () => {
|
this.groupNameInput.addEventListener('input', () => {
|
||||||
let value = this.groupNameInput.value;
|
const value = this.groupNameInput.value;
|
||||||
if(value.length) {
|
this.nextBtn.classList.toggle('is-visible', !!value.length);
|
||||||
this.nextBtn.classList.add('is-visible');
|
|
||||||
} else {
|
|
||||||
this.nextBtn.classList.remove('is-visible');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.nextBtn.addEventListener('click', () => {
|
this.nextBtn.addEventListener('click', () => {
|
||||||
let title = this.groupNameInput.value;
|
const title = this.groupNameInput.value;
|
||||||
|
|
||||||
this.nextBtn.disabled = true;
|
this.nextBtn.disabled = true;
|
||||||
appChatsManager.createChat(title, this.userIDs).then((chatID) => {
|
appChatsManager.createChat(title, this.userIDs).then((chatID) => {
|
||||||
@ -48,11 +44,11 @@ export default class AppNewGroupTab implements SliderTab {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
let chatsContainer = document.createElement('div');
|
const chatsContainer = document.createElement('div');
|
||||||
chatsContainer.classList.add('chats-container');
|
chatsContainer.classList.add('chats-container');
|
||||||
chatsContainer.append(this.searchGroup.container);
|
chatsContainer.append(this.searchGroup.container);
|
||||||
|
|
||||||
let scrollable = new Scrollable(chatsContainer);
|
const scrollable = new Scrollable(chatsContainer);
|
||||||
|
|
||||||
this.contentDiv.append(chatsContainer);
|
this.contentDiv.append(chatsContainer);
|
||||||
}
|
}
|
||||||
@ -64,12 +60,13 @@ export default class AppNewGroupTab implements SliderTab {
|
|||||||
public onCloseAfterTimeout() {
|
public onCloseAfterTimeout() {
|
||||||
this.searchGroup.clear();
|
this.searchGroup.clear();
|
||||||
|
|
||||||
let ctx = this.canvas.getContext('2d');
|
const ctx = this.canvas.getContext('2d');
|
||||||
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
||||||
|
|
||||||
this.uploadAvatar = null;
|
this.uploadAvatar = null;
|
||||||
this.groupNameInput.value = '';
|
this.groupNameInput.value = '';
|
||||||
this.nextBtn.disabled = false;
|
this.nextBtn.disabled = false;
|
||||||
|
this.searchGroup.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(userIDs: number[]) {
|
public init(userIDs: number[]) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user