|
|
@ -5,11 +5,15 @@ import { SettingSection } from "../../sidebarLeft"; |
|
|
|
import Row from "../../row"; |
|
|
|
import Row from "../../row"; |
|
|
|
import CheckboxField from "../../checkboxField"; |
|
|
|
import CheckboxField from "../../checkboxField"; |
|
|
|
import Button from "../../button"; |
|
|
|
import Button from "../../button"; |
|
|
|
import appChatsManager from "../../../lib/appManagers/appChatsManager"; |
|
|
|
import { attachClickEvent, toggleDisability } from "../../../helpers/dom"; |
|
|
|
import { attachClickEvent } from "../../../helpers/dom"; |
|
|
|
|
|
|
|
import appUsersManager from "../../../lib/appManagers/appUsersManager"; |
|
|
|
import appUsersManager from "../../../lib/appManagers/appUsersManager"; |
|
|
|
import appNotificationsManager from "../../../lib/appManagers/appNotificationsManager"; |
|
|
|
import appNotificationsManager from "../../../lib/appManagers/appNotificationsManager"; |
|
|
|
import PeerTitle from "../../peerTitle"; |
|
|
|
import PeerTitle from "../../peerTitle"; |
|
|
|
|
|
|
|
import appMessagesManager from "../../../lib/appManagers/appMessagesManager"; |
|
|
|
|
|
|
|
import rootScope from "../../../lib/rootScope"; |
|
|
|
|
|
|
|
import appPeersManager from "../../../lib/appManagers/appPeersManager"; |
|
|
|
|
|
|
|
import PopupPeer from "../../popups/peer"; |
|
|
|
|
|
|
|
import { addCancelButton } from "../../popups"; |
|
|
|
|
|
|
|
|
|
|
|
export default class AppEditContactTab extends SliderSuperTab { |
|
|
|
export default class AppEditContactTab extends SliderSuperTab { |
|
|
|
private nameInputField: InputField; |
|
|
|
private nameInputField: InputField; |
|
|
@ -64,11 +68,31 @@ export default class AppEditContactTab extends SliderSuperTab { |
|
|
|
text: 'Notifications' |
|
|
|
text: 'Notifications' |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
notificationsCheckboxField.input.addEventListener('change', (e) => { |
|
|
|
|
|
|
|
if(!e.isTrusted) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
appMessagesManager.mutePeer(this.peerId); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.listenerSetter.add(rootScope, 'notify_settings', (update) => { |
|
|
|
|
|
|
|
if(update.peer._ !== 'notifyPeer') return; |
|
|
|
|
|
|
|
const peerId = appPeersManager.getPeerId(update.peer.peer); |
|
|
|
|
|
|
|
if(this.peerId === peerId) { |
|
|
|
|
|
|
|
const enabled = !appNotificationsManager.isMuted(update.notify_settings); |
|
|
|
|
|
|
|
if(enabled !== notificationsCheckboxField.value) { |
|
|
|
|
|
|
|
notificationsCheckboxField.value = enabled; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const notificationsRow = new Row({ |
|
|
|
const notificationsRow = new Row({ |
|
|
|
checkboxField: notificationsCheckboxField |
|
|
|
checkboxField: notificationsCheckboxField |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
notificationsCheckboxField.value = !appNotificationsManager.isPeerLocalMuted(this.peerId, false); |
|
|
|
const enabled = !appNotificationsManager.isPeerLocalMuted(this.peerId, false); |
|
|
|
|
|
|
|
notificationsCheckboxField.value = enabled; |
|
|
|
|
|
|
|
|
|
|
|
const profileNameDiv = document.createElement('div'); |
|
|
|
const profileNameDiv = document.createElement('div'); |
|
|
|
profileNameDiv.classList.add('profile-name'); |
|
|
|
profileNameDiv.classList.add('profile-name'); |
|
|
@ -88,24 +112,8 @@ export default class AppEditContactTab extends SliderSuperTab { |
|
|
|
attachClickEvent(this.editPeer.nextBtn, () => { |
|
|
|
attachClickEvent(this.editPeer.nextBtn, () => { |
|
|
|
this.editPeer.nextBtn.disabled = true; |
|
|
|
this.editPeer.nextBtn.disabled = true; |
|
|
|
|
|
|
|
|
|
|
|
let promises: Promise<any>[] = []; |
|
|
|
appUsersManager.addContact(this.peerId, this.nameInputField.value, this.lastNameInputField.value, appUsersManager.getUser(this.peerId).phone) |
|
|
|
|
|
|
|
.finally(() => { |
|
|
|
const id = -this.peerId; |
|
|
|
|
|
|
|
if(this.nameInputField.isValid()) { |
|
|
|
|
|
|
|
promises.push(appChatsManager.editTitle(id, this.nameInputField.value)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(this.lastNameInputField.isValid()) { |
|
|
|
|
|
|
|
promises.push(appChatsManager.editAbout(id, this.lastNameInputField.value)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(this.editPeer.uploadAvatar) { |
|
|
|
|
|
|
|
promises.push(this.editPeer.uploadAvatar().then(inputFile => { |
|
|
|
|
|
|
|
return appChatsManager.editPhoto(id, inputFile); |
|
|
|
|
|
|
|
})); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Promise.race(promises).finally(() => { |
|
|
|
|
|
|
|
this.editPeer.nextBtn.removeAttribute('disabled'); |
|
|
|
this.editPeer.nextBtn.removeAttribute('disabled'); |
|
|
|
this.close(); |
|
|
|
this.close(); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -119,6 +127,27 @@ export default class AppEditContactTab extends SliderSuperTab { |
|
|
|
|
|
|
|
|
|
|
|
const btnDelete = Button('btn-primary btn-transparent danger', {icon: 'delete', text: 'Delete Contact'}); |
|
|
|
const btnDelete = Button('btn-primary btn-transparent danger', {icon: 'delete', text: 'Delete Contact'}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
attachClickEvent(btnDelete, () => { |
|
|
|
|
|
|
|
new PopupPeer('popup-delete-contact', { |
|
|
|
|
|
|
|
peerId: this.peerId, |
|
|
|
|
|
|
|
title: 'Delete Contact?', |
|
|
|
|
|
|
|
description: `Are you sure you want to delete <b>${appPeersManager.getPeerTitle(this.peerId)}</b> from your contact list?`, |
|
|
|
|
|
|
|
buttons: addCancelButton([{ |
|
|
|
|
|
|
|
text: 'DELETE', |
|
|
|
|
|
|
|
callback: () => { |
|
|
|
|
|
|
|
toggleDisability([btnDelete], true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
appUsersManager.deleteContacts([this.peerId]).then(() => { |
|
|
|
|
|
|
|
this.close(); |
|
|
|
|
|
|
|
}, () => { |
|
|
|
|
|
|
|
toggleDisability([btnDelete], false); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
isDanger: true |
|
|
|
|
|
|
|
}]) |
|
|
|
|
|
|
|
}).show(); |
|
|
|
|
|
|
|
}, {listenerSetter: this.listenerSetter}); |
|
|
|
|
|
|
|
|
|
|
|
section.content.append(btnDelete); |
|
|
|
section.content.append(btnDelete); |
|
|
|
|
|
|
|
|
|
|
|
this.scrollable.append(section.container); |
|
|
|
this.scrollable.append(section.container); |
|
|
|