refactor(adb): decouple auth from dispatcher

This commit is contained in:
Simon Chan 2022-03-03 16:15:56 +08:00
parent a92d80951b
commit 8650537c66
No known key found for this signature in database
GPG key ID: 8F75717685A974FB
28 changed files with 416 additions and 325 deletions

View file

@ -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(() => {