|
|
|
@ -250,28 +250,69 @@ export default class AppPrivacyAndSecurityTab extends SliderSuperTabEventable {
@@ -250,28 +250,69 @@ export default class AppPrivacyAndSecurityTab extends SliderSuperTabEventable {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const promises: Promise<any>[] = []; |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
const section = new SettingSection({name: 'Privacy.SensitiveContent'}); |
|
|
|
|
section.container.classList.add('hide'); |
|
|
|
|
const section = new SettingSection({name: 'NewChatsFromNonContacts', caption: 'ArchiveAndMuteInfo'}); |
|
|
|
|
|
|
|
|
|
promises.push(this.managers.apiManager.invokeApi('account.getContentSettings').then((settings) => { |
|
|
|
|
if(!settings.pFlags.sensitive_can_change) { |
|
|
|
|
const checkboxField = new CheckboxField({text: 'ArchiveAndMute'}); |
|
|
|
|
const row = new Row({ |
|
|
|
|
checkboxField, |
|
|
|
|
noCheckboxSubtitle: true |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
section.content.append(row.container); |
|
|
|
|
|
|
|
|
|
let enabled: boolean, destroyed: boolean; |
|
|
|
|
this.eventListener.addEventListener('destroy', () => { |
|
|
|
|
destroyed = true; |
|
|
|
|
if(enabled === undefined) return; |
|
|
|
|
this.managers.appPrivacyManager.setGlobalPrivacySettings({ |
|
|
|
|
_: 'globalPrivacySettings', |
|
|
|
|
archive_and_mute_new_noncontact_peers: checkboxField.checked |
|
|
|
|
}); |
|
|
|
|
}, {once: true}); |
|
|
|
|
|
|
|
|
|
const promise = Promise.all([ |
|
|
|
|
this.managers.apiManager.getAppConfig(), |
|
|
|
|
this.managers.appPrivacyManager.getGlobalPrivacySettings() |
|
|
|
|
]).then(([appConfig, settings]) => { |
|
|
|
|
if(destroyed) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const enabled = settings.pFlags.sensitive_enabled; |
|
|
|
|
const onPremiumToggle = (isPremium: boolean) => { |
|
|
|
|
section.container.classList.toggle('hide', !isPremium && !appConfig.autoarchive_setting_available); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
this.listenerSetter.add(rootScope)('premium_toggle', onPremiumToggle); |
|
|
|
|
onPremiumToggle(rootScope.premium); |
|
|
|
|
|
|
|
|
|
enabled = settings.archive_and_mute_new_noncontact_peers; |
|
|
|
|
|
|
|
|
|
checkboxField.setValueSilently(enabled); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
promises.push(promise); |
|
|
|
|
|
|
|
|
|
this.scrollable.append(section.container); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
const section = new SettingSection({name: 'Privacy.SensitiveContent', caption: 'PrivacyAndSecurity.SensitiveDesc'}); |
|
|
|
|
section.container.classList.add('hide'); |
|
|
|
|
|
|
|
|
|
const sensitiveRow = new Row({ |
|
|
|
|
checkboxField: new CheckboxField({text: 'PrivacyAndSecurity.SensitiveText', checked: enabled}), |
|
|
|
|
subtitleLangKey: 'PrivacyAndSecurity.SensitiveDesc', |
|
|
|
|
const checkboxField = new CheckboxField({text: 'PrivacyAndSecurity.SensitiveText'}); |
|
|
|
|
const row = new Row({ |
|
|
|
|
checkboxField, |
|
|
|
|
noCheckboxSubtitle: true |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
section.content.append(sensitiveRow.container); |
|
|
|
|
section.container.classList.remove('hide'); |
|
|
|
|
section.content.append(row.container); |
|
|
|
|
|
|
|
|
|
let enabled: boolean; |
|
|
|
|
this.eventListener.addEventListener('destroy', () => { |
|
|
|
|
const _enabled = sensitiveRow.checkboxField.checked; |
|
|
|
|
if(enabled === undefined) return; |
|
|
|
|
const _enabled = row.checkboxField.checked; |
|
|
|
|
const isChanged = _enabled !== enabled; |
|
|
|
|
if(!isChanged) { |
|
|
|
|
return; |
|
|
|
@ -281,48 +322,18 @@ export default class AppPrivacyAndSecurityTab extends SliderSuperTabEventable {
@@ -281,48 +322,18 @@ export default class AppPrivacyAndSecurityTab extends SliderSuperTabEventable {
|
|
|
|
|
sensitive_enabled: _enabled |
|
|
|
|
}); |
|
|
|
|
}, {once: true}); |
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
this.scrollable.append(section.container); |
|
|
|
|
const promise = this.managers.apiManager.invokeApi('account.getContentSettings').then((settings) => { |
|
|
|
|
if(!settings.pFlags.sensitive_can_change) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
const section = new SettingSection({name: 'FilterChats'}); |
|
|
|
|
|
|
|
|
|
const onDeleteClick = () => { |
|
|
|
|
const popup = new PopupPeer('popup-delete-drafts', { |
|
|
|
|
buttons: [{ |
|
|
|
|
langKey: 'Delete', |
|
|
|
|
callback: () => { |
|
|
|
|
const toggle = toggleDisability([deleteButton], true); |
|
|
|
|
this.managers.appDraftsManager.clearAllDrafts().then(() => { |
|
|
|
|
toggle(); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
isDanger: true |
|
|
|
|
}], |
|
|
|
|
titleLangKey: 'AreYouSureClearDraftsTitle', |
|
|
|
|
descriptionLangKey: 'AreYouSureClearDrafts' |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
popup.show(); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const deleteButton = Button('btn-primary btn-transparent', {icon: 'delete', text: 'PrivacyDeleteCloudDrafts'}); |
|
|
|
|
this.listenerSetter.add(deleteButton)('click', onDeleteClick); |
|
|
|
|
section.content.append(deleteButton); |
|
|
|
|
|
|
|
|
|
/* promises.push(apiManager.invokeApi('messages.getAllDrafts').then((drafts) => { |
|
|
|
|
const draftsRow = new Row({ |
|
|
|
|
titleLangKey: 'PrivacyDeleteCloudDrafts', |
|
|
|
|
subtitleLangKey: 'Drafts', |
|
|
|
|
subtitleLangArgs: [(drafts as Updates.updates).updates.length], |
|
|
|
|
icon: 'delete', |
|
|
|
|
clickable: onDeleteClick |
|
|
|
|
enabled = settings.pFlags.sensitive_enabled; |
|
|
|
|
checkboxField.setValueSilently(enabled); |
|
|
|
|
section.container.classList.remove('hide'); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
section.content.append(draftsRow.container); |
|
|
|
|
})); */ |
|
|
|
|
promises.push(promise); |
|
|
|
|
|
|
|
|
|
this.scrollable.append(section.container); |
|
|
|
|
} |
|
|
|
@ -369,6 +380,47 @@ export default class AppPrivacyAndSecurityTab extends SliderSuperTabEventable {
@@ -369,6 +380,47 @@ export default class AppPrivacyAndSecurityTab extends SliderSuperTabEventable {
|
|
|
|
|
this.scrollable.append(section.container); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
const section = new SettingSection({name: 'FilterChats'}); |
|
|
|
|
|
|
|
|
|
const onDeleteClick = () => { |
|
|
|
|
const popup = new PopupPeer('popup-delete-drafts', { |
|
|
|
|
buttons: [{ |
|
|
|
|
langKey: 'Delete', |
|
|
|
|
callback: () => { |
|
|
|
|
const toggle = toggleDisability([deleteButton], true); |
|
|
|
|
this.managers.appDraftsManager.clearAllDrafts().then(() => { |
|
|
|
|
toggle(); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
isDanger: true |
|
|
|
|
}], |
|
|
|
|
titleLangKey: 'AreYouSureClearDraftsTitle', |
|
|
|
|
descriptionLangKey: 'AreYouSureClearDrafts' |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
popup.show(); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const deleteButton = Button('btn-primary btn-transparent', {icon: 'delete', text: 'PrivacyDeleteCloudDrafts'}); |
|
|
|
|
this.listenerSetter.add(deleteButton)('click', onDeleteClick); |
|
|
|
|
section.content.append(deleteButton); |
|
|
|
|
|
|
|
|
|
/* promises.push(apiManager.invokeApi('messages.getAllDrafts').then((drafts) => { |
|
|
|
|
const draftsRow = new Row({ |
|
|
|
|
titleLangKey: 'PrivacyDeleteCloudDrafts', |
|
|
|
|
subtitleLangKey: 'Drafts', |
|
|
|
|
subtitleLangArgs: [(drafts as Updates.updates).updates.length], |
|
|
|
|
icon: 'delete', |
|
|
|
|
clickable: onDeleteClick |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
section.content.append(draftsRow.container); |
|
|
|
|
})); */ |
|
|
|
|
|
|
|
|
|
this.scrollable.append(section.container); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return Promise.all(promises); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|