|
| 1 | +import {createEffect, createResource, For} from 'solid-js'; |
| 2 | +import {logger} from '../../../../lib/logger'; |
| 3 | +import {useHotReloadGuard} from '../../../../lib/solidjs/hotReloadGuard'; |
| 4 | +import {useSuperTab} from '../../../solidJsTabs/superTabProvider'; |
| 5 | +import {type AppAdminRecentActionsTab} from '../../../solidJsTabs/tabs'; |
| 6 | +import {LogEntry} from './logEntry'; |
| 7 | +import {IconTsx} from '../../../iconTsx'; |
| 8 | + |
| 9 | +const log = logger('AdminRecentActionsTab'); |
| 10 | + |
| 11 | +const AdminRecentActionsTab = () => { |
| 12 | + const {rootScope, PeerTitleTsx} = useHotReloadGuard(); |
| 13 | + const [tab] = useSuperTab<typeof AppAdminRecentActionsTab>(); |
| 14 | + |
| 15 | + const [logs] = createResource(async() => { |
| 16 | + const startTime = performance.now(); |
| 17 | + const result = await rootScope.managers.appChatsManager.getAdminLogs({channelId: tab.payload.channelId}) |
| 18 | + const endTime = performance.now(); |
| 19 | + |
| 20 | + log(`getAdminLogs took ${endTime - startTime}ms`); |
| 21 | + |
| 22 | + return result; |
| 23 | + }); |
| 24 | + |
| 25 | + createEffect(() => { |
| 26 | + console.log('logs :>> ', logs()); |
| 27 | + }); |
| 28 | + |
| 29 | + return ( |
| 30 | + <For each={logs() || []}> |
| 31 | + {(log) => ( |
| 32 | + <div style={{padding: '6px 12px'}}> |
| 33 | + <LogEntry |
| 34 | + peerTitle={<PeerTitleTsx peerId={log.user_id.toPeerId()} />} |
| 35 | + // peerTitle={'lsdfkj alsdfj alskdjf alskdjf alsdkfj alsdkfja lsdkjf asldfj'} |
| 36 | + // message={'Chnaged the title from This to That and edited some messages'} |
| 37 | + message={'Chnaged the title from This to That'} |
| 38 | + date={new Date(log.date * 1000)} |
| 39 | + icon='clipboard' |
| 40 | + // expandableContent={<div> |
| 41 | + // lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. |
| 42 | + // </div>} |
| 43 | + /> |
| 44 | + </div> |
| 45 | + )} |
| 46 | + </For> |
| 47 | + ); |
| 48 | +}; |
| 49 | + |
| 50 | +/** |
| 51 | + * - cases for each log action type |
| 52 | + * - infinite scroll fetching |
| 53 | + * - dynamic virtual list |
| 54 | + * - collapsing |
| 55 | + * - filters |
| 56 | + * - downloading log |
| 57 | + */ |
| 58 | + |
| 59 | +export default AdminRecentActionsTab; |
0 commit comments