You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-11-24 23:01:05 +03:00
DM: Simplify session components API (#1745)
Co-authored-by: Quentin Gliech <quenting@element.io>
This commit is contained in:
@@ -24,6 +24,7 @@ import {
|
||||
parseUserAgent,
|
||||
sessionNameFromDeviceInformation,
|
||||
} from "../utils/parseUserAgent";
|
||||
import { useCurrentBrowserSessionId } from "../utils/session/useCurrentBrowserSessionId";
|
||||
|
||||
import EndSessionButton from "./Session/EndSessionButton";
|
||||
import Session from "./Session/Session";
|
||||
@@ -92,11 +93,12 @@ export const useEndBrowserSession = (
|
||||
|
||||
type Props = {
|
||||
session: FragmentType<typeof BROWSER_SESSION_FRAGMENT>;
|
||||
isCurrent: boolean;
|
||||
};
|
||||
|
||||
const BrowserSession: React.FC<Props> = ({ session, isCurrent }) => {
|
||||
const BrowserSession: React.FC<Props> = ({ session }) => {
|
||||
const currentBrowserSessionId = useCurrentBrowserSessionId();
|
||||
const data = useFragment(BROWSER_SESSION_FRAGMENT, session);
|
||||
const isCurrent = data.id === currentBrowserSessionId;
|
||||
|
||||
const onSessionEnd = useEndBrowserSession(data.id, isCurrent);
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import {
|
||||
Pagination,
|
||||
} from "../pagination";
|
||||
import { isOk, unwrap, unwrapOk } from "../result";
|
||||
import { useCurrentBrowserSessionId } from "../utils/session/useCurrentBrowserSessionId";
|
||||
|
||||
import BlockList from "./BlockList";
|
||||
import BrowserSession from "./BrowserSession";
|
||||
@@ -112,7 +111,6 @@ const paginationFamily = atomFamily((userId: string) => {
|
||||
});
|
||||
|
||||
const BrowserSessionList: React.FC<{ userId: string }> = ({ userId }) => {
|
||||
const currentBrowserSessionId = useCurrentBrowserSessionId();
|
||||
const [pending, startTransition] = useTransition();
|
||||
const result = useAtomValue(browserSessionListFamily(userId));
|
||||
const setPagination = useSetAtom(currentPaginationAtom);
|
||||
@@ -157,11 +155,7 @@ const BrowserSessionList: React.FC<{ userId: string }> = ({ userId }) => {
|
||||
Active only
|
||||
</label>
|
||||
{browserSessions.edges.map((n) => (
|
||||
<BrowserSession
|
||||
key={n.cursor}
|
||||
session={n.node}
|
||||
isCurrent={n.node.id === currentBrowserSessionId}
|
||||
/>
|
||||
<BrowserSession key={n.cursor} session={n.node} />
|
||||
))}
|
||||
</BlockList>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user