|
|
@ -7,8 +7,8 @@ |
|
|
|
import appChatsManager from "../../lib/appManagers/appChatsManager"; |
|
|
|
import appChatsManager from "../../lib/appManagers/appChatsManager"; |
|
|
|
import appMessagesManager from "../../lib/appManagers/appMessagesManager"; |
|
|
|
import appMessagesManager from "../../lib/appManagers/appMessagesManager"; |
|
|
|
import rootScope from "../../lib/rootScope"; |
|
|
|
import rootScope from "../../lib/rootScope"; |
|
|
|
import { addCancelButton, PopupButton } from "."; |
|
|
|
import { addCancelButton } from "."; |
|
|
|
import PopupPeer from "./peer"; |
|
|
|
import PopupPeer, { PopupPeerButtonCallbackCheckboxes, PopupPeerOptions } from "./peer"; |
|
|
|
import { ChatType } from "../chat/chat"; |
|
|
|
import { ChatType } from "../chat/chat"; |
|
|
|
import { i18n, LangPackKey } from "../../lib/langPack"; |
|
|
|
import { i18n, LangPackKey } from "../../lib/langPack"; |
|
|
|
import PeerTitle from "../peerTitle"; |
|
|
|
import PeerTitle from "../peerTitle"; |
|
|
@ -21,16 +21,16 @@ export default class PopupDeleteMessages { |
|
|
|
}).element; |
|
|
|
}).element; |
|
|
|
|
|
|
|
|
|
|
|
mids = mids.slice(); |
|
|
|
mids = mids.slice(); |
|
|
|
const callback = (revoke?: true) => { |
|
|
|
const callback = (checked: PopupPeerButtonCallbackCheckboxes, revoke?: boolean) => { |
|
|
|
onConfirm && onConfirm(); |
|
|
|
onConfirm && onConfirm(); |
|
|
|
if(type === 'scheduled') { |
|
|
|
if(type === 'scheduled') { |
|
|
|
appMessagesManager.deleteScheduledMessages(peerId, mids); |
|
|
|
appMessagesManager.deleteScheduledMessages(peerId, mids); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
appMessagesManager.deleteMessages(peerId, mids, revoke); |
|
|
|
appMessagesManager.deleteMessages(peerId, mids, !!checked.size || revoke); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
let title: LangPackKey, titleArgs: any[], description: LangPackKey, descriptionArgs: any[], buttons: PopupButton[]; |
|
|
|
let title: LangPackKey, titleArgs: any[], description: LangPackKey, descriptionArgs: any[], buttons: PopupPeerOptions['buttons'], checkboxes: PopupPeerOptions['checkboxes'] = []; |
|
|
|
if(mids.length === 1) { |
|
|
|
if(mids.length === 1) { |
|
|
|
title = 'DeleteSingleMessagesTitle'; |
|
|
|
title = 'DeleteSingleMessagesTitle'; |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -43,18 +43,16 @@ export default class PopupDeleteMessages { |
|
|
|
buttons = [{ |
|
|
|
buttons = [{ |
|
|
|
langKey: 'Delete', |
|
|
|
langKey: 'Delete', |
|
|
|
isDanger: true, |
|
|
|
isDanger: true, |
|
|
|
callback: () => callback() |
|
|
|
callback |
|
|
|
}]; |
|
|
|
}]; |
|
|
|
|
|
|
|
|
|
|
|
if(peerId === rootScope.myId || type === 'scheduled') { |
|
|
|
if(peerId === rootScope.myId || type === 'scheduled') { |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if(peerId > 0) { |
|
|
|
if(peerId > 0) { |
|
|
|
buttons.push({ |
|
|
|
checkboxes.push({ |
|
|
|
langKey: 'DeleteMessagesOptionAlso', |
|
|
|
text: 'DeleteMessagesOptionAlso', |
|
|
|
langArgs: [peerTitleElement], |
|
|
|
textArgs: [peerTitleElement] |
|
|
|
isDanger: true, |
|
|
|
|
|
|
|
callback: () => callback(true) |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
const chat = appChatsManager.getChat(-peerId); |
|
|
|
const chat = appChatsManager.getChat(-peerId); |
|
|
@ -68,16 +66,12 @@ export default class PopupDeleteMessages { |
|
|
|
|
|
|
|
|
|
|
|
if(canRevoke.length) { |
|
|
|
if(canRevoke.length) { |
|
|
|
if(canRevoke.length === mids.length) { |
|
|
|
if(canRevoke.length === mids.length) { |
|
|
|
buttons.push({ |
|
|
|
checkboxes.push({ |
|
|
|
langKey: 'DeleteForAll', |
|
|
|
text: 'DeleteForAll' |
|
|
|
isDanger: true, |
|
|
|
|
|
|
|
callback: () => callback(true) |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
buttons.push({ |
|
|
|
checkboxes.push({ |
|
|
|
langKey: 'DeleteMessagesOption', |
|
|
|
text: 'DeleteMessagesOption' |
|
|
|
isDanger: true, |
|
|
|
|
|
|
|
callback: () => callback(true) |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
description = 'DeleteMessagesTextGroup'; |
|
|
|
description = 'DeleteMessagesTextGroup'; |
|
|
@ -86,7 +80,7 @@ export default class PopupDeleteMessages { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
buttons[0].callback = () => callback(true); |
|
|
|
buttons[0].callback = (checked) => callback(checked, true); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -99,7 +93,8 @@ export default class PopupDeleteMessages { |
|
|
|
titleLangArgs: titleArgs, |
|
|
|
titleLangArgs: titleArgs, |
|
|
|
descriptionLangKey: description, |
|
|
|
descriptionLangKey: description, |
|
|
|
descriptionLangArgs: descriptionArgs, |
|
|
|
descriptionLangArgs: descriptionArgs, |
|
|
|
buttons |
|
|
|
buttons, |
|
|
|
|
|
|
|
checkboxes |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
popup.show(); |
|
|
|
popup.show(); |
|
|
|