devex: address PR feedback

- move App#initSessions definition outside function component closure
- enhance useAddSessions performance
This commit is contained in:
tomholford 2022-04-11 12:05:25 -07:00
parent d3f9d76217
commit 50d120e3c1
3 changed files with 10 additions and 12 deletions

View File

@ -21,18 +21,18 @@ import { DEFAULT_SESSION } from './constants';
import { showSlog } from './lib/blit';
import { InfoButton } from './InfoButton';
const initSessions = async () => {
const response = await api.scry(scrySessions());
useTermState.getState().set((state) => {
state.names = response.sort();
});
};
export default function TermApp() {
const { names, selected } = useTermState();
const dark = useDark();
const initSessions = useCallback(async () => {
const response = await api.scry(scrySessions());
useTermState.getState().set((state) => {
state.names = response.sort();
});
}, []);
const setupSlog = useCallback(() => {
console.log('slog: setting up...');
let available = false;

View File

@ -6,7 +6,7 @@ import { Icon } from '@tlon/indigo-react';
export const Tabs = () => {
const { sessions, names } = useTermState();
const { addSession } = useAddSession();
const addSession = useAddSession();
return (
<div className="tabs">

View File

@ -62,7 +62,5 @@ export const useAddSession = () => {
}
}, [names]);
return {
addSession
};
return addSession;
};