T
This commit is contained in:
parent
18734bc5aa
commit
6bb932a371
@ -15,7 +15,7 @@ import rootScope from "../../../lib/rootScope";
|
|||||||
import AppEditFolderTab from "./editFolder";
|
import AppEditFolderTab from "./editFolder";
|
||||||
import Row from "../../row";
|
import Row from "../../row";
|
||||||
import { SettingSection } from "..";
|
import { SettingSection } from "..";
|
||||||
import { i18n, i18n_, LangPackKey } from "../../../lib/langPack";
|
import { i18n, i18n_, LangPackKey, join } from "../../../lib/langPack";
|
||||||
|
|
||||||
export default class AppChatFoldersTab extends SliderSuperTab {
|
export default class AppChatFoldersTab extends SliderSuperTab {
|
||||||
private createFolderBtn: HTMLElement;
|
private createFolderBtn: HTMLElement;
|
||||||
@ -76,14 +76,7 @@ export default class AppChatFoldersTab extends SliderSuperTab {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if(d.length) {
|
if(d.length) {
|
||||||
let arr: HTMLElement[] = d.slice(0, 1);
|
const arr = join(d);
|
||||||
for(let i = 1; i < d.length; ++i) {
|
|
||||||
const isLast = (d.length - 1) === i;
|
|
||||||
const delimiterKey: LangPackKey = isLast ? 'WordDelimiterLast' : 'WordDelimiter';
|
|
||||||
arr.push(i18n(delimiterKey));
|
|
||||||
arr.push(d[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
arr.forEach(el => {
|
arr.forEach(el => {
|
||||||
row.subtitle.append(el);
|
row.subtitle.append(el);
|
||||||
});
|
});
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
import { SliderSuperTab } from "../../slider";
|
import { SliderSuperTab } from "../../slider";
|
||||||
import AppSelectPeers from "../../appSelectPeers";
|
import AppSelectPeers from "../../appSelectPeers";
|
||||||
import appDialogsManager from "../../../lib/appManagers/appDialogsManager";
|
import appDialogsManager from "../../../lib/appManagers/appDialogsManager";
|
||||||
import appPeersManager from "../../../lib/appManagers/appPeersManager";
|
|
||||||
import appUsersManager from "../../../lib/appManagers/appUsersManager";
|
import appUsersManager from "../../../lib/appManagers/appUsersManager";
|
||||||
import { MyDialogFilter as DialogFilter } from "../../../lib/storages/filters";
|
import { MyDialogFilter as DialogFilter } from "../../../lib/storages/filters";
|
||||||
import rootScope from "../../../lib/rootScope";
|
|
||||||
import { copy } from "../../../helpers/object";
|
import { copy } from "../../../helpers/object";
|
||||||
import ButtonIcon from "../../buttonIcon";
|
import ButtonIcon from "../../buttonIcon";
|
||||||
import CheckboxField from "../../checkboxField";
|
import CheckboxField from "../../checkboxField";
|
||||||
import Button from "../../button";
|
import Button from "../../button";
|
||||||
import AppEditFolderTab from "./editFolder";
|
import AppEditFolderTab from "./editFolder";
|
||||||
import { i18n, LangPackKey, _i18n } from "../../../lib/langPack";
|
import { i18n, LangPackKey, _i18n, join } from "../../../lib/langPack";
|
||||||
|
import appMessagesManager from "../../../lib/appManagers/appMessagesManager";
|
||||||
|
import RichTextProcessor from "../../../lib/richtextprocessor";
|
||||||
|
|
||||||
export default class AppIncludedChatsTab extends SliderSuperTab {
|
export default class AppIncludedChatsTab extends SliderSuperTab {
|
||||||
private editFolderTab: AppEditFolderTab;
|
private editFolderTab: AppEditFolderTab;
|
||||||
@ -21,7 +21,9 @@ export default class AppIncludedChatsTab extends SliderSuperTab {
|
|||||||
private filter: DialogFilter;
|
private filter: DialogFilter;
|
||||||
private originalFilter: DialogFilter;
|
private originalFilter: DialogFilter;
|
||||||
|
|
||||||
init() {
|
private dialogsByFilters: Map<DialogFilter, Set<number>>;
|
||||||
|
|
||||||
|
protected init() {
|
||||||
this.content.remove();
|
this.content.remove();
|
||||||
this.container.classList.add('included-chatlist-container');
|
this.container.classList.add('included-chatlist-container');
|
||||||
this.confirmBtn = ButtonIcon('check btn-confirm blue', {noRipple: true});
|
this.confirmBtn = ButtonIcon('check btn-confirm blue', {noRipple: true});
|
||||||
@ -92,6 +94,13 @@ export default class AppIncludedChatsTab extends SliderSuperTab {
|
|||||||
this.editFolderTab.setFilter(this.filter, false);
|
this.editFolderTab.setFilter(this.filter, false);
|
||||||
this.close();
|
this.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.dialogsByFilters = new Map();
|
||||||
|
appMessagesManager.filtersStorage.getDialogFilters().then(filters => {
|
||||||
|
for(const filter of filters) {
|
||||||
|
this.dialogsByFilters.set(filter, new Set(appMessagesManager.dialogsStorage.getFolder(filter.id).map(d => d.peerId)));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
checkbox(selected?: boolean) {
|
checkbox(selected?: boolean) {
|
||||||
@ -124,6 +133,19 @@ export default class AppIncludedChatsTab extends SliderSuperTab {
|
|||||||
dom.containerEl.append(this.checkbox(selected));
|
dom.containerEl.append(this.checkbox(selected));
|
||||||
if(selected) dom.listEl.classList.add('active');
|
if(selected) dom.listEl.classList.add('active');
|
||||||
|
|
||||||
|
const foundInFilters: HTMLElement[] = [];
|
||||||
|
this.dialogsByFilters.forEach((dialogs, filter) => {
|
||||||
|
if(dialogs.has(peerId)) {
|
||||||
|
const span = document.createElement('span');
|
||||||
|
span.innerHTML = RichTextProcessor.wrapEmojiText(filter.title);
|
||||||
|
foundInFilters.push(span);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const joined = join(foundInFilters, false);
|
||||||
|
joined.forEach(el => {
|
||||||
|
dom.lastMessageSpan.append(el);
|
||||||
|
});
|
||||||
/* let subtitle: LangPackKey;
|
/* let subtitle: LangPackKey;
|
||||||
|
|
||||||
if(peerId > 0) {
|
if(peerId > 0) {
|
||||||
|
@ -230,4 +230,16 @@ export {i18n_};
|
|||||||
const _i18n = I18n._i18n;
|
const _i18n = I18n._i18n;
|
||||||
export {_i18n};
|
export {_i18n};
|
||||||
|
|
||||||
|
export function join(elements: HTMLElement[], useLast = true) {
|
||||||
|
const arr: HTMLElement[] = elements.slice(0, 1);
|
||||||
|
for(let i = 1; i < elements.length; ++i) {
|
||||||
|
const isLast = (elements.length - 1) === i;
|
||||||
|
const delimiterKey: LangPackKey = isLast && useLast ? 'WordDelimiterLast' : 'WordDelimiter';
|
||||||
|
arr.push(i18n(delimiterKey));
|
||||||
|
arr.push(elements[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.I18n = I18n);
|
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.I18n = I18n);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user