Browse Source

Some popup fixes

master
Eduard Kuzmenko 3 years ago
parent
commit
36022a478b
  1. 37
      src/components/popups/deleteMessages.ts
  2. 7
      src/components/popups/sendNow.ts
  3. 33
      src/components/popups/unpinMessage.ts
  4. 1
      src/lang.ts
  5. 6
      src/lib/appManagers/appMessagesManager.ts

37
src/components/popups/deleteMessages.ts

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

7
src/components/popups/sendNow.ts

@ -21,15 +21,10 @@ export default class PopupSendNow { @@ -21,15 +21,10 @@ export default class PopupSendNow {
};
buttons.push({
text: 'SEND',
langKey: 'Send',
callback
});
buttons.push({
text: 'CANCEL',
isCancel: true
});
const popup = new PopupPeer('popup-delete-chat', {
peerId,
title,

33
src/components/popups/unpinMessage.ts

@ -5,8 +5,8 @@ @@ -5,8 +5,8 @@
*/
import appMessagesManager from "../../lib/appManagers/appMessagesManager";
import { addCancelButton, PopupButton } from ".";
import PopupPeer from "./peer";
import { addCancelButton } from ".";
import PopupPeer, { PopupPeerButtonCallbackCheckboxes, PopupPeerOptions } from "./peer";
import appPeersManager from "../../lib/appManagers/appPeersManager";
import rootScope from "../../lib/rootScope";
import { LangPackKey } from "../../lib/langPack";
@ -15,11 +15,11 @@ import PeerTitle from "../peerTitle"; @@ -15,11 +15,11 @@ import PeerTitle from "../peerTitle";
export default class PopupPinMessage {
constructor(peerId: number, mid: number, unpin?: true, onConfirm?: () => void) {
let title: LangPackKey, description: LangPackKey, buttons: PopupButton[] = [];
let title: LangPackKey, description: LangPackKey, buttons: PopupPeerOptions['buttons'] = [], checkboxes: PopupPeerOptions['checkboxes'] = [];
const canUnpin = appPeersManager.canPinMessage(peerId);
const callback = (oneSide?: true, silent?: true) => {
const callback = (checked: PopupPeerButtonCallbackCheckboxes, oneSide?: boolean, silent?: boolean) => {
setTimeout(() => { // * костыль, потому что document.elementFromPoint вернёт popup-peer пока он будет закрываться
let promise: Promise<any>;
if(unpin && !mid) {
@ -57,7 +57,7 @@ export default class PopupPinMessage { @@ -57,7 +57,7 @@ export default class PopupPinMessage {
buttons.push({
langKey: buttonText,
isDanger: true,
callback: () => callback()
callback
});
} else {
title = 'PinMessageAlertTitle';
@ -66,7 +66,7 @@ export default class PopupPinMessage { @@ -66,7 +66,7 @@ export default class PopupPinMessage {
if(peerId < 0) {
buttons.push({
langKey: pinButtonText,
callback: () => callback()
callback: (checked) => callback(checked, false, !checked.size)
});
if(appChatsManager.isBroadcast(-peerId)) {
@ -74,9 +74,9 @@ export default class PopupPinMessage { @@ -74,9 +74,9 @@ export default class PopupPinMessage {
} else {
description = 'PinMessageAlert';
buttons.push({
langKey: 'PinNotify',
callback: () => callback(undefined, true)
checkboxes.push({
text: 'PinNotify',
checked: true
});
}
} else {
@ -85,18 +85,18 @@ export default class PopupPinMessage { @@ -85,18 +85,18 @@ export default class PopupPinMessage {
if(peerId === rootScope.myId) {
buttons.push({
langKey: pinButtonText,
callback: () => callback()
callback
});
} else {
buttons.push({
langKey: pinButtonText,
callback: () => callback(true)
callback: (checked) => callback(checked, !checked.size)
});
buttons.push({
langKey: 'PinAlsoFor',
langArgs: [new PeerTitle({peerId, onlyFirstName: true}).element],
callback: () => callback()
checkboxes.push({
text: 'PinAlsoFor',
textArgs: [new PeerTitle({peerId, onlyFirstName: true}).element],
checked: true
});
}
}
@ -108,7 +108,8 @@ export default class PopupPinMessage { @@ -108,7 +108,8 @@ export default class PopupPinMessage {
peerId,
titleLangKey: title,
descriptionLangKey: description,
buttons
buttons,
checkboxes
});
popup.show();

1
src/lang.ts

@ -523,6 +523,7 @@ const lang = { @@ -523,6 +523,7 @@ const lang = {
"AppName": "Telegram",
"OK": "OK",
"PinFolderLimitReached": "Sorry, you can\'t pin any more chats to the top.",
"Send": "Send",
// * macos
"AccountSettings.Filters": "Chat Folders",

6
src/lib/appManagers/appMessagesManager.ts

@ -2077,12 +2077,12 @@ export class AppMessagesManager { @@ -2077,12 +2077,12 @@ export class AppMessagesManager {
});
}
public updatePinnedMessage(peerId: number, mid: number, unpin?: true, silent?: true, oneSide?: true) {
public updatePinnedMessage(peerId: number, mid: number, unpin?: boolean, silent?: boolean, pm_oneside?: boolean) {
return apiManager.invokeApi('messages.updatePinnedMessage', {
peer: appPeersManager.getInputPeerById(peerId),
unpin,
silent,
pm_oneside: oneSide,
pm_oneside,
id: this.getServerMessageId(mid)
}).then(updates => {
//this.log('pinned updates:', updates);
@ -3540,7 +3540,7 @@ export class AppMessagesManager { @@ -3540,7 +3540,7 @@ export class AppMessagesManager {
});
}
public deleteMessages(peerId: number, mids: number[], revoke?: true) {
public deleteMessages(peerId: number, mids: number[], revoke?: boolean) {
let promise: Promise<any>;
const localMessageIds = mids.map(mid => this.getServerMessageId(mid));

Loading…
Cancel
Save