diff options
author | bobzel <zzzman@gmail.com> | 2023-12-10 20:19:27 -0500 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2023-12-10 20:19:27 -0500 |
commit | 380ee1acac1c0b7972d7d423cf804af146dc0edf (patch) | |
tree | 1d77244a600e6eb1fb6d56356b3ce01ca6add89d /src/Utils.ts | |
parent | b7b7105fac83ec11480204c5c7ac0ae6579774e1 (diff) |
massive changes to use mobx 6 which means not accessing props directly in @computed functions.
Diffstat (limited to 'src/Utils.ts')
-rw-r--r-- | src/Utils.ts | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Utils.ts b/src/Utils.ts index 26514622c..d54760100 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -7,6 +7,7 @@ import { DocumentType } from './client/documents/DocumentTypes'; import { Colors } from './client/views/global/globalEnums'; import { Message } from './server/Message'; import * as Color from 'color'; +import { action, makeObservable } from 'mobx'; export namespace Utils { export let CLICK_TIME = 300; @@ -439,6 +440,12 @@ export namespace Utils { socket.on(message, (room: any) => handler(socket, room)); } } +export function copyProps(thing: { _prevProps: any; props: any; _props: any }) { + Object.keys(thing._prevProps).forEach(action(pkey => + (thing._prevProps as any)[pkey] !== (thing.props as any)[pkey] && + ((thing._props as any)[pkey] = (thing.props as any)[pkey]))); // prettier-ignore + thing._prevProps = thing.props; +} export function OmitKeys(obj: any, keys: string[], pattern?: string, addKeyFunc?: (dup: any) => void): { omit: any; extract: any } { const omit: any = { ...obj }; |