Browse Source

Fix add members

master
morethanwords 4 years ago
parent
commit
fa73477a9e
  1. 16
      src/components/sidebarLeft/addMembers.ts
  2. 19
      src/components/sidebarLeft/newGroup.ts

16
src/components/sidebarLeft/addMembers.ts

@ -13,11 +13,16 @@ export default class AppAddMembersTab implements SliderTab { @@ -13,11 +13,16 @@ export default class AppAddMembersTab implements SliderTab {
private peerType: 'channel' | 'chat';
private peerID: number; // always positive
private takeOut: (peerIDs: number[]) => void
private skippable: boolean;
constructor() {
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(this.takeOut) {
this.takeOut(peerIDs);
@ -43,13 +48,14 @@ export default class AppAddMembersTab implements SliderTab { @@ -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.peerType = type;
this.takeOut = takeOut;
this.skippable = skippable;
this.onCloseAfterTimeout();
this.selector = new AppSelectPeers(this.contentDiv, skipable ? null : (length) => {
this.selector = new AppSelectPeers(this.contentDiv, skippable ? null : (length) => {
if(length) {
this.nextBtn.classList.add('is-visible');
} else {
@ -60,7 +66,7 @@ export default class AppAddMembersTab implements SliderTab { @@ -60,7 +66,7 @@ export default class AppAddMembersTab implements SliderTab {
this.nextBtn.innerHTML = '';
this.nextBtn.disabled = false;
this.nextBtn.classList.add('tgico-next');
if(skipable) {
if(skippable) {
this.nextBtn.classList.add('is-visible');
} else {
this.nextBtn.classList.remove('is-visible');

19
src/components/sidebarLeft/newGroup.ts

@ -13,7 +13,7 @@ export default class AppNewGroupTab implements SliderTab { @@ -13,7 +13,7 @@ export default class AppNewGroupTab implements SliderTab {
private canvas = this.container.querySelector('.avatar-edit-canvas') as HTMLCanvasElement;
private groupNameInput = this.container.querySelector('.new-group-name') as HTMLInputElement;
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 userIDs: number[];
@ -25,16 +25,12 @@ export default class AppNewGroupTab implements SliderTab { @@ -25,16 +25,12 @@ export default class AppNewGroupTab implements SliderTab {
});
this.groupNameInput.addEventListener('input', () => {
let value = this.groupNameInput.value;
if(value.length) {
this.nextBtn.classList.add('is-visible');
} else {
this.nextBtn.classList.remove('is-visible');
}
const value = this.groupNameInput.value;
this.nextBtn.classList.toggle('is-visible', !!value.length);
});
this.nextBtn.addEventListener('click', () => {
let title = this.groupNameInput.value;
const title = this.groupNameInput.value;
this.nextBtn.disabled = true;
appChatsManager.createChat(title, this.userIDs).then((chatID) => {
@ -48,11 +44,11 @@ export default class AppNewGroupTab implements SliderTab { @@ -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.append(this.searchGroup.container);
let scrollable = new Scrollable(chatsContainer);
const scrollable = new Scrollable(chatsContainer);
this.contentDiv.append(chatsContainer);
}
@ -64,12 +60,13 @@ export default class AppNewGroupTab implements SliderTab { @@ -64,12 +60,13 @@ export default class AppNewGroupTab implements SliderTab {
public onCloseAfterTimeout() {
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);
this.uploadAvatar = null;
this.groupNameInput.value = '';
this.nextBtn.disabled = false;
this.searchGroup.clear();
}
public init(userIDs: number[]) {

Loading…
Cancel
Save