Fix starting multiselect from grouped documents

This commit is contained in:
morethanwords 2021-09-15 16:02:09 +04:00
parent 0014fd6319
commit 44a915a31c
4 changed files with 72 additions and 41 deletions

View File

@ -35,6 +35,7 @@ import isInDOM from "../../helpers/dom/isInDOM";
import { randomLong } from "../../helpers/random"; import { randomLong } from "../../helpers/random";
import { attachContextMenuListener } from "../misc"; import { attachContextMenuListener } from "../misc";
import { attachClickEvent, AttachClickOptions } from "../../helpers/dom/clickEvent"; import { attachClickEvent, AttachClickOptions } from "../../helpers/dom/clickEvent";
import findUpAsChild from "../../helpers/dom/findUpAsChild";
const accumulateMapSet = (map: Map<number, Set<number>>) => { const accumulateMapSet = (map: Map<number, Set<number>>) => {
return [...map.values()].reduce((acc, v) => acc + v.size, 0); return [...map.values()].reduce((acc, v) => acc + v.size, 0);
@ -136,6 +137,8 @@ class AppSelection {
const slice = elements.slice(firstIndex + 1, lastIndex); const slice = elements.slice(firstIndex + 1, lastIndex);
console.log('getElementsBetween', first, last, slice, firstIndex, lastIndex, isHigher);
return slice; return slice;
}; };
@ -190,8 +193,16 @@ class AppSelection {
seenSet.add(mid); seenSet.add(mid);
if((selecting && !isSelected) || (!selecting && isSelected)) { if((selecting && !isSelected) || (!selecting && isSelected)) {
const seenLength = accumulateMapSet(seen);
if(this.toggleByElement && checkBetween) { if(this.toggleByElement && checkBetween) {
if(seenLength < 2) {
if(findUpAsChild(element, firstTarget)) {
firstTarget = element;
}
}
const elementsBetween = getElementsBetween(firstTarget, element); const elementsBetween = getElementsBetween(firstTarget, element);
console.log(elementsBetween);
if(elementsBetween.length) { if(elementsBetween.length) {
elementsBetween.forEach(element => { elementsBetween.forEach(element => {
processElement(element, false); processElement(element, false);
@ -200,7 +211,7 @@ class AppSelection {
} }
if(!this.selectedMids.size) { if(!this.selectedMids.size) {
if(accumulateMapSet(seen) === 2 && this.toggleByMid) { if(seenLength === 2 && this.toggleByMid) {
for(const [peerId, mids] of seen) { for(const [peerId, mids] of seen) {
for(const mid of mids) { for(const mid of mids) {
this.toggleByMid(peerId, mid); this.toggleByMid(peerId, mid);

View File

@ -255,8 +255,7 @@ export default class AppEditChatTab extends SliderSuperTab {
if(!isBroadcast && appChatsManager.hasRights(this.chatId, 'change_permissions')) { if(!isBroadcast && appChatsManager.hasRights(this.chatId, 'change_permissions')) {
const showChatHistoryCheckboxField = new CheckboxField({ const showChatHistoryCheckboxField = new CheckboxField({
text: 'ChatHistory', text: 'ChatHistory',
withRipple: true, withRipple: true
checked: !(chatFull as ChatFull.channelFull).pFlags.hidden_prehistory
}); });
this.listenerSetter.add(showChatHistoryCheckboxField.input)('change', () => { this.listenerSetter.add(showChatHistoryCheckboxField.input)('change', () => {
@ -266,9 +265,12 @@ export default class AppEditChatTab extends SliderSuperTab {
}); });
}); });
addChatUpdateListener(() => { const onChatUpdate = () => {
showChatHistoryCheckboxField.setValueSilently(!(chatFull as ChatFull.channelFull).pFlags.hidden_prehistory); showChatHistoryCheckboxField.setValueSilently(isChannel && !(chatFull as ChatFull.channelFull).pFlags.hidden_prehistory);
}); };
onChatUpdate();
addChatUpdateListener(onChatUpdate);
section.content.append(showChatHistoryCheckboxField.label); section.content.append(showChatHistoryCheckboxField.label);
} }

View File

@ -288,8 +288,10 @@ export default class AppGroupPermissionsTab extends SliderSuperTabEventable {
}; };
let exceptionsCount = 0; let exceptionsCount = 0;
let loader: ScrollableLoader;
const setLoader = () => {
const LOAD_COUNT = 50; const LOAD_COUNT = 50;
const loader = new ScrollableLoader({ loader = new ScrollableLoader({
scrollable: this.scrollable, scrollable: this.scrollable,
getPromise: () => { getPromise: () => {
return appProfileManager.getChannelParticipants(this.chatId, {_: 'channelParticipantsBanned', q: ''}, LOAD_COUNT, list.childElementCount).then(res => { return appProfileManager.getChannelParticipants(this.chatId, {_: 'channelParticipantsBanned', q: ''}, LOAD_COUNT, list.childElementCount).then(res => {
@ -305,9 +307,23 @@ export default class AppGroupPermissionsTab extends SliderSuperTabEventable {
} }
}); });
return loader.load();
};
this.scrollable.append(section.container); this.scrollable.append(section.container);
await loader.load(); if(appChatsManager.isChannel(this.chatId)) {
await setLoader();
} else {
setLength();
this.listenerSetter.add(rootScope)('dialog_migrate', ({migrateFrom, migrateTo}) => {
if(this.chatId === migrateFrom) {
this.chatId = migrateTo;
setLoader();
}
});
}
} }
} }

View File

@ -32,6 +32,7 @@ let onFirstMount = () => {
return loadFonts().then(() => { return loadFonts().then(() => {
return new Promise<void>((resolve) => { return new Promise<void>((resolve) => {
window.requestAnimationFrame(() => { window.requestAnimationFrame(() => {
// setTimeout(() => {
const promise = import('../lib/appManagers/appDialogsManager'); const promise = import('../lib/appManagers/appDialogsManager');
promise.finally(async() => { promise.finally(async() => {
//alert('pageIm!'); //alert('pageIm!');
@ -50,8 +51,9 @@ let onFirstMount = () => {
//(Array.from(document.getElementsByClassName('rp')) as HTMLElement[]).forEach(el => ripple(el)); //(Array.from(document.getElementsByClassName('rp')) as HTMLElement[]).forEach(el => ripple(el));
}); });
// }, 5e3);
}); });
}); })
}); });
//let promise = /* Promise.resolve() */.then(() => {//import('../lib/services').then(services => { //let promise = /* Promise.resolve() */.then(() => {//import('../lib/services').then(services => {