Added delete cloud drafts button
This commit is contained in:
parent
54262b004b
commit
babbfdb3d7
@ -7,7 +7,7 @@
|
|||||||
import { SliderSuperTabEventable } from "../../sliderTab";
|
import { SliderSuperTabEventable } from "../../sliderTab";
|
||||||
import { SettingSection } from "..";
|
import { SettingSection } from "..";
|
||||||
import Row from "../../row";
|
import Row from "../../row";
|
||||||
import { AccountPassword, Authorization, InputPrivacyKey } from "../../../layer";
|
import { AccountPassword, Authorization, InputPrivacyKey, Updates } from "../../../layer";
|
||||||
import appPrivacyManager, { PrivacyType } from "../../../lib/appManagers/appPrivacyManager";
|
import appPrivacyManager, { PrivacyType } from "../../../lib/appManagers/appPrivacyManager";
|
||||||
import AppPrivacyPhoneNumberTab from "./privacy/phoneNumber";
|
import AppPrivacyPhoneNumberTab from "./privacy/phoneNumber";
|
||||||
import AppTwoStepVerificationTab from "./2fa";
|
import AppTwoStepVerificationTab from "./2fa";
|
||||||
@ -28,12 +28,15 @@ import { convertKeyToInputKey } from "../../../helpers/string";
|
|||||||
import { i18n, LangPackKey, _i18n } from "../../../lib/langPack";
|
import { i18n, LangPackKey, _i18n } from "../../../lib/langPack";
|
||||||
import replaceContent from "../../../helpers/dom/replaceContent";
|
import replaceContent from "../../../helpers/dom/replaceContent";
|
||||||
import CheckboxField from "../../checkboxField";
|
import CheckboxField from "../../checkboxField";
|
||||||
|
import PopupPeer from "../../popups/peer";
|
||||||
|
import appDraftsManager from "../../../lib/appManagers/appDraftsManager";
|
||||||
|
import Button from "../../button";
|
||||||
|
|
||||||
export default class AppPrivacyAndSecurityTab extends SliderSuperTabEventable {
|
export default class AppPrivacyAndSecurityTab extends SliderSuperTabEventable {
|
||||||
private activeSessionsRow: Row;
|
private activeSessionsRow: Row;
|
||||||
private authorizations: Authorization.authorization[];
|
private authorizations: Authorization.authorization[];
|
||||||
|
|
||||||
protected async init() {
|
protected init() {
|
||||||
this.container.classList.add('dont-u-dare-block-me');
|
this.container.classList.add('dont-u-dare-block-me');
|
||||||
this.setTitle('PrivacySettings');
|
this.setTitle('PrivacySettings');
|
||||||
|
|
||||||
@ -226,14 +229,16 @@ export default class AppPrivacyAndSecurityTab extends SliderSuperTabEventable {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const promises: Promise<any>[] = [];
|
||||||
{
|
{
|
||||||
await apiManager.invokeApi('account.getContentSettings').then(settings => {
|
const section = new SettingSection({name: 'Privacy.SensitiveContent'});
|
||||||
|
|
||||||
|
promises.push(apiManager.invokeApi('account.getContentSettings').then(settings => {
|
||||||
if(!settings.pFlags.sensitive_can_change) {
|
if(!settings.pFlags.sensitive_can_change) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const enabled = settings.pFlags.sensitive_enabled;
|
const enabled = settings.pFlags.sensitive_enabled;
|
||||||
const section = new SettingSection({name: 'Privacy.SensitiveContent'});
|
|
||||||
|
|
||||||
const sensitiveRow = new Row({
|
const sensitiveRow = new Row({
|
||||||
checkboxField: new CheckboxField({text: 'PrivacyAndSecurity.SensitiveText', checked: enabled}),
|
checkboxField: new CheckboxField({text: 'PrivacyAndSecurity.SensitiveText', checked: enabled}),
|
||||||
@ -243,21 +248,62 @@ export default class AppPrivacyAndSecurityTab extends SliderSuperTabEventable {
|
|||||||
|
|
||||||
section.content.append(sensitiveRow.container);
|
section.content.append(sensitiveRow.container);
|
||||||
|
|
||||||
this.scrollable.append(section.container);
|
|
||||||
|
|
||||||
this.eventListener.addEventListener('destroy', () => {
|
this.eventListener.addEventListener('destroy', () => {
|
||||||
const _enabled = sensitiveRow.checkboxField.checked;
|
const _enabled = sensitiveRow.checkboxField.checked;
|
||||||
const isChanged = _enabled !== enabled;
|
const isChanged = _enabled !== enabled;
|
||||||
if(!isChanged) {
|
if(!isChanged) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
apiManager.invokeApi('account.setContentSettings', {
|
apiManager.invokeApi('account.setContentSettings', {
|
||||||
sensitive_enabled: _enabled
|
sensitive_enabled: _enabled
|
||||||
});
|
});
|
||||||
}, true);
|
}, true);
|
||||||
});
|
}));
|
||||||
|
|
||||||
|
this.scrollable.append(section.container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const section = new SettingSection({name: 'FilterChats'});
|
||||||
|
|
||||||
|
const onDeleteClick = () => {
|
||||||
|
const popup = new PopupPeer('popup-delete-drafts', {
|
||||||
|
buttons: [{
|
||||||
|
langKey: 'Delete',
|
||||||
|
callback: () => {
|
||||||
|
appDraftsManager.clearAllDrafts();
|
||||||
|
},
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateActiveSessions() {
|
public updateActiveSessions() {
|
||||||
|
@ -17,7 +17,7 @@ const App = {
|
|||||||
id: 1025907,
|
id: 1025907,
|
||||||
hash: '452b0359b988148995f22ff0f4229750',
|
hash: '452b0359b988148995f22ff0f4229750',
|
||||||
version: '0.5.9',
|
version: '0.5.9',
|
||||||
langPackVersion: '0.2.9',
|
langPackVersion: '0.3.0',
|
||||||
langPack: 'macos',
|
langPack: 'macos',
|
||||||
langPackCode: 'en',
|
langPackCode: 'en',
|
||||||
domains: [MAIN_DOMAIN] as string[],
|
domains: [MAIN_DOMAIN] as string[],
|
||||||
|
@ -54,6 +54,10 @@ const lang = {
|
|||||||
"ConnectionStatus.Waiting": "Waiting for network...",
|
"ConnectionStatus.Waiting": "Waiting for network...",
|
||||||
"Deactivated.Title": "Too many tabs...",
|
"Deactivated.Title": "Too many tabs...",
|
||||||
"Deactivated.Subtitle": "Telegram supports only one active tab with the app.\nClick anywhere to continue using this tab.",
|
"Deactivated.Subtitle": "Telegram supports only one active tab with the app.\nClick anywhere to continue using this tab.",
|
||||||
|
/* "Drafts": {
|
||||||
|
"one_value": "%d draft",
|
||||||
|
"other_value": "%d drafts",
|
||||||
|
}, */
|
||||||
"General.Keyboard": "Keyboard",
|
"General.Keyboard": "Keyboard",
|
||||||
"General.SendShortcut.Enter": "Send by Enter",
|
"General.SendShortcut.Enter": "Send by Enter",
|
||||||
"General.SendShortcut.CtrlEnter": "Send by %s + Enter",
|
"General.SendShortcut.CtrlEnter": "Send by %s + Enter",
|
||||||
@ -486,6 +490,9 @@ const lang = {
|
|||||||
"ViaBot": "via",
|
"ViaBot": "via",
|
||||||
"InviteExpired": "This invite link has expired.",
|
"InviteExpired": "This invite link has expired.",
|
||||||
"NoUsernameFound": "There is no Telegram account with this username.",
|
"NoUsernameFound": "There is no Telegram account with this username.",
|
||||||
|
"PrivacyDeleteCloudDrafts": "Delete All Cloud Drafts",
|
||||||
|
"AreYouSureClearDraftsTitle": "Delete cloud drafts",
|
||||||
|
"AreYouSureClearDrafts": "Are you sure you want to delete all cloud drafts?",
|
||||||
|
|
||||||
// * macos
|
// * macos
|
||||||
"AccountSettings.Filters": "Chat Folders",
|
"AccountSettings.Filters": "Chat Folders",
|
||||||
|
@ -227,6 +227,24 @@ export class AppDraftsManager {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public clearAllDrafts() {
|
||||||
|
return apiManager.invokeApi('messages.clearAllDrafts').then(bool => {
|
||||||
|
if(!bool) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(const peerId in this.drafts) {
|
||||||
|
const splitted = peerId.split('_');
|
||||||
|
const threadId = splitted[1];
|
||||||
|
rootScope.dispatchEvent('draft_updated', {
|
||||||
|
peerId: +splitted[0],
|
||||||
|
threadId: threadId ? +threadId : undefined,
|
||||||
|
draft: undefined
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const appDraftsManager = new AppDraftsManager();
|
const appDraftsManager = new AppDraftsManager();
|
||||||
|
Loading…
Reference in New Issue
Block a user