| 1 | import type { PreviewViewportSetting } from "@t3tools/contracts"; |
| 2 | |
| 3 | import { browserViewportSettingKey } from "~/browser/browserViewportLayout"; |
| 4 | |
| 5 | export function shouldRollbackPreviewViewport( |
| 6 | previous: PreviewViewportSetting, |
| 7 | requested: PreviewViewportSetting, |
| 8 | latest: PreviewViewportSetting, |
| 9 | operationServerEpoch: string | null, |
| 10 | currentServerEpoch: string | null, |
| 11 | ): boolean { |
| 12 | const requestedKey = browserViewportSettingKey(requested); |
| 13 | return ( |
| 14 | currentServerEpoch === operationServerEpoch && |
| 15 | browserViewportSettingKey(latest) === requestedKey && |
| 16 | browserViewportSettingKey(previous) !== requestedKey |
| 17 | ); |
| 18 | } |