Archive and mute
This commit is contained in:
parent
3266d1d4c6
commit
df2f809565
src
@ -250,79 +250,90 @@ export default class AppPrivacyAndSecurityTab extends SliderSuperTabEventable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const promises: Promise<any>[] = [];
|
const promises: Promise<any>[] = [];
|
||||||
{
|
|
||||||
const section = new SettingSection({name: 'Privacy.SensitiveContent'});
|
|
||||||
section.container.classList.add('hide');
|
|
||||||
|
|
||||||
promises.push(this.managers.apiManager.invokeApi('account.getContentSettings').then((settings) => {
|
{
|
||||||
if(!settings.pFlags.sensitive_can_change) {
|
const section = new SettingSection({name: 'NewChatsFromNonContacts', caption: 'ArchiveAndMuteInfo'});
|
||||||
|
|
||||||
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const enabled = settings.pFlags.sensitive_enabled;
|
const onPremiumToggle = (isPremium: boolean) => {
|
||||||
|
section.container.classList.toggle('hide', !isPremium && !appConfig.autoarchive_setting_available);
|
||||||
|
};
|
||||||
|
|
||||||
const sensitiveRow = new Row({
|
this.listenerSetter.add(rootScope)('premium_toggle', onPremiumToggle);
|
||||||
checkboxField: new CheckboxField({text: 'PrivacyAndSecurity.SensitiveText', checked: enabled}),
|
onPremiumToggle(rootScope.premium);
|
||||||
subtitleLangKey: 'PrivacyAndSecurity.SensitiveDesc',
|
|
||||||
noCheckboxSubtitle: true
|
|
||||||
});
|
|
||||||
|
|
||||||
section.content.append(sensitiveRow.container);
|
enabled = settings.archive_and_mute_new_noncontact_peers;
|
||||||
section.container.classList.remove('hide');
|
|
||||||
|
|
||||||
this.eventListener.addEventListener('destroy', () => {
|
checkboxField.setValueSilently(enabled);
|
||||||
const _enabled = sensitiveRow.checkboxField.checked;
|
});
|
||||||
const isChanged = _enabled !== enabled;
|
|
||||||
if(!isChanged) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.managers.apiManager.invokeApi('account.setContentSettings', {
|
promises.push(promise);
|
||||||
sensitive_enabled: _enabled
|
|
||||||
});
|
|
||||||
}, {once: true});
|
|
||||||
}));
|
|
||||||
|
|
||||||
this.scrollable.append(section.container);
|
this.scrollable.append(section.container);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const section = new SettingSection({name: 'FilterChats'});
|
const section = new SettingSection({name: 'Privacy.SensitiveContent', caption: 'PrivacyAndSecurity.SensitiveDesc'});
|
||||||
|
section.container.classList.add('hide');
|
||||||
|
|
||||||
const onDeleteClick = () => {
|
const checkboxField = new CheckboxField({text: 'PrivacyAndSecurity.SensitiveText'});
|
||||||
const popup = new PopupPeer('popup-delete-drafts', {
|
const row = new Row({
|
||||||
buttons: [{
|
checkboxField,
|
||||||
langKey: 'Delete',
|
noCheckboxSubtitle: true
|
||||||
callback: () => {
|
});
|
||||||
const toggle = toggleDisability([deleteButton], true);
|
|
||||||
this.managers.appDraftsManager.clearAllDrafts().then(() => {
|
section.content.append(row.container);
|
||||||
toggle();
|
|
||||||
});
|
let enabled: boolean;
|
||||||
},
|
this.eventListener.addEventListener('destroy', () => {
|
||||||
isDanger: true
|
if(enabled === undefined) return;
|
||||||
}],
|
const _enabled = row.checkboxField.checked;
|
||||||
titleLangKey: 'AreYouSureClearDraftsTitle',
|
const isChanged = _enabled !== enabled;
|
||||||
descriptionLangKey: 'AreYouSureClearDrafts'
|
if(!isChanged) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.managers.apiManager.invokeApi('account.setContentSettings', {
|
||||||
|
sensitive_enabled: _enabled
|
||||||
});
|
});
|
||||||
|
}, {once: true});
|
||||||
|
|
||||||
popup.show();
|
const promise = this.managers.apiManager.invokeApi('account.getContentSettings').then((settings) => {
|
||||||
};
|
if(!settings.pFlags.sensitive_can_change) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const deleteButton = Button('btn-primary btn-transparent', {icon: 'delete', text: 'PrivacyDeleteCloudDrafts'});
|
enabled = settings.pFlags.sensitive_enabled;
|
||||||
this.listenerSetter.add(deleteButton)('click', onDeleteClick);
|
checkboxField.setValueSilently(enabled);
|
||||||
section.content.append(deleteButton);
|
section.container.classList.remove('hide');
|
||||||
|
});
|
||||||
|
|
||||||
/* promises.push(apiManager.invokeApi('messages.getAllDrafts').then((drafts) => {
|
promises.push(promise);
|
||||||
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);
|
this.scrollable.append(section.container);
|
||||||
}
|
}
|
||||||
@ -369,6 +380,47 @@ export default class AppPrivacyAndSecurityTab extends SliderSuperTabEventable {
|
|||||||
this.scrollable.append(section.container);
|
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);
|
return Promise.all(promises);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* https://github.com/morethanwords/tweb/blob/master/LICENSE
|
* https://github.com/morethanwords/tweb/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {InputPrivacyKey, InputPrivacyRule, PrivacyRule, PrivacyKey} from '../../layer';
|
import {InputPrivacyKey, InputPrivacyRule, PrivacyRule, PrivacyKey, GlobalPrivacySettings} from '../../layer';
|
||||||
import convertInputKeyToKey from '../../helpers/string/convertInputKeyToKey';
|
import convertInputKeyToKey from '../../helpers/string/convertInputKeyToKey';
|
||||||
import {AppManager} from './manager';
|
import {AppManager} from './manager';
|
||||||
|
|
||||||
@ -72,4 +72,12 @@ export class AppPrivacyManager extends AppManager {
|
|||||||
return this.privacy[privacyKey] = privacyRules.rules;
|
return this.privacy[privacyKey] = privacyRules.rules;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getGlobalPrivacySettings() {
|
||||||
|
return this.apiManager.invokeApi('account.getGlobalPrivacySettings')
|
||||||
|
}
|
||||||
|
|
||||||
|
public setGlobalPrivacySettings(settings: GlobalPrivacySettings) {
|
||||||
|
return this.apiManager.invokeApi('account.setGlobalPrivacySettings', {settings});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user