@@ -78,7 +78,7 @@ import {NULL_PEER_ID} from '@appManagers/constants';
7878import createParticipantContextMenu from '@helpers/dom/createParticipantContextMenu' ;
7979import findAndSpliceAll from '@helpers/array/findAndSpliceAll' ;
8080import deferredPromise from '@helpers/cancellablePromise' ;
81- import { createEffect , createRoot , on } from 'solid-js' ;
81+ import { children , createEffect , createRoot , For , on } from 'solid-js' ;
8282import StoriesProfileList from '@components/stories/profileList' ;
8383import Button from '@components/button' ;
8484import anchorCallback from '@helpers/dom/anchorCallback' ;
@@ -109,6 +109,7 @@ import {AutonomousSavedDialogList} from '@components/autonomousDialogList/savedD
109109import SetTransition from '@components/singleTransition' ;
110110import liteMode from '@helpers/liteMode' ;
111111import { wrapGlobalPostsSearch } from './sidebarLeft/globalPostsSearch' ;
112+ import createMiddleware from '@helpers/solid/createMiddleware' ;
112113
113114// const testScroll = false;
114115
@@ -1473,29 +1474,48 @@ export default class AppSearchSuper {
14731474
14741475 this . searchGroups . recent . list . replaceChildren ( ) ;
14751476
1476- appState . recentSearch . slice ( 0 , 20 ) . forEach ( async ( peerId ) => {
1477- const { dom} = appDialogsManager . addDialogNew ( {
1478- peerId : peerId ,
1479- container : this . searchGroups . recent . list ,
1480- meAsSaved : true ,
1481- avatarSize : 'abitbigger' ,
1482- autonomous : true ,
1483- wrapOptions : {
1484- middleware
1485- } ,
1486- withStories : true
1477+ createRoot ( ( dispose ) => {
1478+ middleware . onClean ( dispose ) ;
1479+
1480+ const arr = For ( {
1481+ each : appState . recentSearch ,
1482+ children : ( peerId ) => {
1483+ const middlewareHelper = createMiddleware ( ) ;
1484+ const { dom} = appDialogsManager . addDialogNew ( {
1485+ peerId : peerId ,
1486+ container : false ,
1487+ meAsSaved : true ,
1488+ avatarSize : 'abitbigger' ,
1489+ autonomous : true ,
1490+ wrapOptions : {
1491+ middleware : middlewareHelper . get ( )
1492+ } ,
1493+ withStories : true
1494+ } ) ;
1495+
1496+ ( async ( ) => {
1497+ dom . lastMessageSpan . append ( await ( peerId . isUser ( ) ?
1498+ Promise . resolve ( getUserStatusString ( await this . managers . appUsersManager . getUser ( peerId . toUserId ( ) ) ) ) :
1499+ getChatMembersString ( peerId . toChatId ( ) ) ) ) ;
1500+ } ) ( ) ;
1501+
1502+ return dom . containerEl ;
1503+ }
14871504 } ) ;
14881505
1489- dom . lastMessageSpan . append ( await ( peerId . isUser ( ) ?
1490- Promise . resolve ( getUserStatusString ( await this . managers . appUsersManager . getUser ( peerId . toUserId ( ) ) ) ) :
1491- getChatMembersString ( peerId . toChatId ( ) ) ) ) ;
1492- } ) ;
1506+ const elements = children ( ( ) => arr ) ;
1507+ createEffect ( ( ) => {
1508+ this . searchGroups . recent . list . replaceChildren ( ... ( elements . toArray ( ) as HTMLElement [ ] ) ) ;
1509+ } ) ;
14931510
1494- if ( ! appState . recentSearch . length ) {
1495- this . searchGroups . recent . clear ( ) ;
1496- } else if ( setActive ) {
1497- this . searchGroups . recent . setActive ( ) ;
1498- }
1511+ createEffect ( ( ) => {
1512+ if ( ! appState . recentSearch . length ) {
1513+ this . searchGroups . recent . clear ( ) ;
1514+ } else if ( setActive ) {
1515+ this . searchGroups . recent . setActive ( ) ;
1516+ }
1517+ } ) ;
1518+ } ) ;
14991519 } ;
15001520
15011521 return Promise . all ( [
0 commit comments