ca1213c32f
Fix chat date blinking Fix displaying sent messages to new dialog Scroll to date bubble if message is bigger than viewport Fix releasing keyboard by inline helper Fix clearing self user Fix displaying sent public poll Update contacts counter in dialogs placeholder Improve multiselect animation Disable lottie icon animations if they're disabled Fix changing mtproto transport during authorization
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
/*
|
|
* https://github.com/morethanwords/tweb
|
|
* Copyright (C) 2019-2021 Eduard Kuzmenko
|
|
* https://github.com/morethanwords/tweb/blob/master/LICENSE
|
|
*/
|
|
|
|
import { addCancelButton } from "./popups";
|
|
import PopupPeer, { PopupPeerOptions } from "./popups/peer";
|
|
|
|
// type PopupConfirmationOptions = Pick<PopupPeerOptions, 'titleLangKey'>;
|
|
type PopupConfirmationOptions = PopupPeerOptions & {
|
|
button: PopupPeerOptions['buttons'][0],
|
|
checkbox?: PopupPeerOptions['checkboxes'][0]
|
|
};
|
|
|
|
export default function confirmationPopup(options: PopupConfirmationOptions) {
|
|
return new Promise<boolean | void>((resolve, reject) => {
|
|
const {button, checkbox} = options;
|
|
button.callback = (set) => {
|
|
resolve(set ? !!set.size : undefined);
|
|
};
|
|
|
|
const buttons = addCancelButton([button]);
|
|
const cancelButton = buttons.find(button => button.isCancel);
|
|
cancelButton.callback = () => {
|
|
reject();
|
|
};
|
|
|
|
options.buttons = buttons;
|
|
options.checkboxes = checkbox && [checkbox];
|
|
|
|
new PopupPeer('popup-confirmation', options).show();
|
|
});
|
|
}
|