mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-05 19:42:15 +02:00
refactor(adb): decouple auth from dispatcher
This commit is contained in:
parent
a92d80951b
commit
8650537c66
28 changed files with 416 additions and 325 deletions
|
@ -1,5 +1,5 @@
|
|||
import { IconButton, IListProps, List, mergeStyles, mergeStyleSets, Stack } from '@fluentui/react';
|
||||
import { AdbPacketInit, decodeUtf8 } from '@yume-chan/adb';
|
||||
import { AdbPacketCore, decodeUtf8 } from '@yume-chan/adb';
|
||||
import { DisposableList } from '@yume-chan/event';
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { PropsWithChildren, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
||||
|
@ -23,7 +23,7 @@ const classNames = mergeStyleSets({
|
|||
},
|
||||
});
|
||||
|
||||
function serializePacket(packet: AdbPacketInit) {
|
||||
function serializePacket(packet: AdbPacketCore) {
|
||||
const command = decodeUtf8(new Uint32Array([packet.command]));
|
||||
|
||||
const parts = [
|
||||
|
@ -44,7 +44,7 @@ function serializePacket(packet: AdbPacketInit) {
|
|||
return parts.join(' ');
|
||||
}
|
||||
|
||||
const LogLine = withDisplayName('LoggerLine')(({ packet }: { packet: [string, AdbPacketInit]; }) => {
|
||||
const LogLine = withDisplayName('LoggerLine')(({ packet }: { packet: [string, AdbPacketCore]; }) => {
|
||||
const string = useMemo(() => serializePacket(packet[1]), [packet]);
|
||||
|
||||
return (
|
||||
|
@ -69,11 +69,11 @@ export interface LoggerProps {
|
|||
className?: string;
|
||||
}
|
||||
|
||||
function shouldVirtualize(props: IListProps<[string, AdbPacketInit]>) {
|
||||
function shouldVirtualize(props: IListProps<[string, AdbPacketCore]>) {
|
||||
return !!props.items && props.items.length > 100;
|
||||
}
|
||||
|
||||
function renderCell(item?: [string, AdbPacketInit]) {
|
||||
function renderCell(item?: [string, AdbPacketCore]) {
|
||||
if (!item) {
|
||||
return null;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ function renderCell(item?: [string, AdbPacketInit]) {
|
|||
export const LogView = observer(({
|
||||
className,
|
||||
}: LoggerProps) => {
|
||||
const [packets, setPackets] = useState<[string, AdbPacketInit][]>([]);
|
||||
const [packets, setPackets] = useState<[string, AdbPacketCore][]>([]);
|
||||
const scrollerRef = useRef<HTMLDivElement | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue