Skip to content

Commit

Permalink
improve code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed Aug 14, 2024
1 parent 351c479 commit e4041ec
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => {
const authUser = useAuthUser();
const facility = useSlug("facility");
const bed = props.consultationData.current_bed?.bed_object;
const feedStateSessionKey = getFeedStateKey(props.consultationId);
const feedStateSessionKey = `encounterFeedState[${props.consultationId}]`;

const [asset, setAsset] = useState<AssetData>();
const [preset, setPreset] = useState<AssetBedModel>();
Expand Down Expand Up @@ -126,17 +126,16 @@ export const ConsultationFeedTab = (props: ConsultationTabProps) => {
}, [!!bed, loading, !!asset, divRef.current]);

useEffect(() => {
const feedPresetKey = getFeedStateKey(props.consultationId);
if (preset?.id) {
sessionStorage.setItem(
feedPresetKey,
feedStateSessionKey,
JSON.stringify({
type: "preset",
value: preset.id,
} satisfies LastAccessedPreset),
);
}
}, [preset, props.consultationId]);
}, [feedStateSessionKey, preset]);

if (loading) {
return <Loading />;
Expand Down Expand Up @@ -271,7 +270,3 @@ type LastAccessedPosition = {
};

type LastFeedState = LastAccessedPosition | LastAccessedPreset;

const getFeedStateKey = (consultationId: string) => {
return `encounterFeedState[${consultationId}]`;
};

0 comments on commit e4041ec

Please sign in to comment.