Skip to content

Commit

Permalink
fix(structure): only reset history params if needed (#8284)
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrobonamin authored Jan 16, 2025
1 parent 5a98259 commit d52c0ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ export type DocumentChangeContextInstance = {
documentId: string
schemaType: SchemaType
rootDiff: ObjectDiff | null
/**
* This decides if the diff shows the reverting changes button or not.
*/
isComparingCurrent: boolean
FieldWrapper: ComponentType<{path: Path; children: ReactNode; hasHover: boolean}>
value: Partial<SanityDocument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export function useResetHistoryParams() {
const isMounted = useRef(false)

const updateHistoryParams = useEffectEvent((_perspective?: string) => {
// Check if any of the history related params are set, and reset them, don't unnecessarily update the params
const PARAMS_TO_UPDATE = ['since', 'historyVersion', 'rev', 'preserveRev']
const shouldUpdateParams = PARAMS_TO_UPDATE.some((param) => params[param])
if (!shouldUpdateParams) return

setParams({
...params,
// Reset the history related params when the perspective changes, as they don't make sense
Expand Down

0 comments on commit d52c0ac

Please sign in to comment.