openreplay/frontend/app/mstore/uiPlayerStore.ts
Delirium a71381da40
getting rid of redux for good (#2556)
* start moving ui to redux tlk

* remove unused reducer

* changes for gdpr and site types

* ui: migrating duck/roles to mobx

* ui: drop unreferenced types

* ui: drop unreferenced types

* ui: move player slice reducer to mobx family

* ui: move assignments to issueReportingStore.ts

* remove issues store

* some fixes after issues store

* remove errors reducer, drop old components

* finish removing errors reducer

* start moving integrations state to mobx

* change(ui): funnel duck cleanup

* change(ui): custom fields

* change(ui): customMetrics cleanup

* change(ui): customMetrics cleanup

* change(ui): duck/filters minor cleanup

* change(ui): duck/filters cleanup

* change(ui): duck/customMetrics cleanup and upgrades

* fix integrations service, fix babel config to >.25 + not ie

* refactoring integrations reducers etc WIP

* finish removing integrations state

* some fixes for integrated check

* start of projects refactoring

* move api and "few" files to new project store

* new batch for site -> projects

* fix setid context

* move all critical components, drop site duck

* remove all duck/site refs, remove old components

* fixup for SessionTags.tsx, remove duck/sources (?)

* move session store

* init sessionstore outside of context

* fix userfilter

* replace simple actions for session store

* sessions sotre

* Rtm temp (#2597)

* change(ui): duck/search wip

* change(ui): duck/search wip

* change(ui): duck/search wip

* change(ui): duck/searchLive wip

* change(ui): duck/searchLive wip

* change(ui): duck/searchLive wip

* change(ui): duck/searchLive wip

* change(ui): search states

* change(ui): search states

* change(ui): search states

* change(ui): fix savedSearch store

* change(ui): fix savedSearch store

* some fixes for session connector

* change(ui): fix savedSearch store

* change(ui): fix searchLive

* change(ui): fix searchLive

* fixes for session replay

* change(ui): bookmark fetch

* last components for sessions

* add fetchautoplaylist

* finish session reducer, remove deleted reducers

* change(ui): fix the search fetch

* change(ui): fix the search fetch

* fix integrations call ctx

* ensure ctx for sessionstore

* fix(ui): checking for latest sessions path

* start removing user reducer

* removing user reducer pt2...

* finish user store

* remove rand log

* fix crashes

* tinkering workflow file for tracker test

* making sure prefetched sessions work properly

* fix conflict

* fix router redirects during loading

---------

Co-authored-by: Shekar Siri <sshekarsiri@gmail.com>
2024-10-03 11:38:36 +02:00

110 lines
No EOL
2.5 KiB
TypeScript

import { makeAutoObservable } from 'mobx';
interface ToggleZoomPayload {
enabled: boolean;
range?: [number, number];
}
export const NONE = 0;
export const CONSOLE = 1;
export const NETWORK = 2;
export const STACKEVENTS = 3;
export const STORAGE = 4;
export const PROFILER = 5;
export const PERFORMANCE = 6;
export const GRAPHQL = 7;
export const FETCH = 8;
export const EXCEPTIONS = 9;
export const INSPECTOR = 11;
export const OVERVIEW = 12;
export const blocks = {
none: NONE,
console: CONSOLE,
network: NETWORK,
stackEvents: STACKEVENTS,
storage: STORAGE,
profiler: PROFILER,
performance: PERFORMANCE,
graphql: GRAPHQL,
fetch: FETCH,
exceptions: EXCEPTIONS,
inspector: INSPECTOR,
overview: OVERVIEW,
} as const;
export const blockValues = [
NONE,
CONSOLE,
NETWORK,
STACKEVENTS,
STORAGE,
PROFILER,
PERFORMANCE,
GRAPHQL,
FETCH,
EXCEPTIONS,
INSPECTOR,
OVERVIEW,
] as const;
export default class UiPlayerStore {
fullscreen = false;
bottomBlock = 0;
hiddenHints = {
storage: localStorage.getItem('storageHideHint') || undefined,
stack: localStorage.getItem('stackHideHint') || undefined,
};
skipInterval: 2 | 5 | 10 | 15 | 20 | 30 | 60 = parseInt(localStorage.getItem('CHANGE_SKIP_INTERVAL') || '10', 10) as (2 | 5 | 10 | 15 | 20 | 30 | 60)
timelineZoom = {
enabled: false,
startTs: 0,
endTs: 0,
}
zoomTab: 'overview' | 'journey' | 'issues' | 'errors' = 'overview'
constructor() {
makeAutoObservable(this);
}
toggleFullscreen = (val?: boolean) => {
this.fullscreen = val ?? !this.fullscreen;
}
fullscreenOff = () => {
this.fullscreen = false;
}
fullscreenOn = () => {
this.fullscreen = true;
}
toggleBottomBlock = (block: number) => {
this.bottomBlock = this.bottomBlock === block ? 0 : block;
}
closeBottomBlock = () => {
this.bottomBlock = 0;
}
changeSkipInterval = (interval: 2 | 5 | 10 | 15 | 20 | 30 | 60) => {
localStorage.setItem('CHANGE_SKIP_INTERVAL', interval.toString());
this.skipInterval = interval;
}
hideHint = (hint: 'storage' | 'stack') => {
this.hiddenHints[hint] = 'true';
localStorage.setItem(`${hint}HideHint`, 'true');
this.bottomBlock = 0;
}
toggleZoom = (payload: ToggleZoomPayload) => {
this.timelineZoom.enabled = payload.enabled;
this.timelineZoom.startTs = payload.range?.[0] ?? 0;
this.timelineZoom.endTs = payload.range?.[1] ?? 0;
}
setZoomTab = (tab: 'overview' | 'journey' | 'issues' | 'errors') => {
this.zoomTab = tab;
}
}