added settingsStore to infoPanel store and moved normalizeSelection and getItemIcon as methods

This commit is contained in:
mushka 2022-09-08 04:25:13 +03:00
parent f78f4b1ce0
commit 36f233035d
2 changed files with 42 additions and 5 deletions

View File

@ -128,6 +128,8 @@ const profileActionsStore = new ProfileActionsStore(
peopleStore
);
authStore.infoPanelStore.setSettingsStore(settingsStore);
const store = {
auth: authStore,
payments: paymentStore,

View File

@ -1,10 +1,18 @@
import { makeAutoObservable } from "mobx";
class InfoPanelStore {
selection = null;
isVisible = false;
roomView = "members";
itemView = "history";
selection = null;
currentRoomTitle = null;
currentRoomMembers = null;
roomsView = "members";
personalView = "history";
settingsStore = null;
setSettingsStore = (settingsStore) => (this.settingsStore = settingsStore);
constructor() {
makeAutoObservable(this);
@ -14,6 +22,33 @@ class InfoPanelStore {
this.selection = selection;
};
getItemIcon = (item, size) => {
return item.isRoom
? item.logo && item.logo.big
? item.logo.big
: item.icon
: item.isFolder
? this.settingsStore.getFolderIcon(item.providerKey, size)
: this.settingsStore.getIcon(size, item.fileExst || ".file");
};
normalizeSelection = (selection) => {
return {
...selection,
icon: this.getItemIcon(selection, 32),
hasCustonThumbnail: !!selection.thumbnailUrl,
thumbnailUrl: selection.thumbnailUrl || this.getItemIcon(selection, 96),
};
};
setCurrentRoomTitle = (currentRoomTitle) => {
this.currentRoomTitle = currentRoomTitle;
};
setCurrentRoomMembers = (currentRoomMembers) => {
this.currentRoomMembers = currentRoomMembers;
};
toggleIsVisible = () => {
this.isVisible = !this.isVisible;
};
@ -27,8 +62,8 @@ class InfoPanelStore {
};
setView = (view) => {
this.roomView = view;
this.itemView = view === "members" ? "history" : view;
this.roomsView = view;
this.personalView = view === "members" ? "history" : view;
};
}