Skip to content

Rewrite notes

Jayant edited this page Aug 11, 2023 · 5 revisions

Rewrite notes

  • rewriting plugin into Typescript
  • making the code more modular to allow more flexibility in adding new features/conditionss

Personal notes

  • Triggers

    • go AFK
      • joining afk vc
      • timeout
      • discord idle mode event
    • go unAFK
      • focused timeout
      • discord unidle mode event
      • sending a message on discord
      • leaving afk vc
  • Conditions to check

    instead of oop magic, can just have simple if/else's in hierarchy check that. because it is hard to figure out a hierarchical way to add that condition

    all enabled via a toggle, and all fail fast

    • going AFK
      • current status == trigger status
      • ongoign discord activity
      • not in vc (calls post evaluate callback)
    • going unAFK
      • afk set by plugin == true opposite = (multi device mode ^)
      • current status == afkstatus
  • AFK: enable / disable

    • post evaluate callback
    • post afk callbacks
      • change user status
    • post unAFK callbacks

timeouts:

global timeout id
onFocus and onBlur both cancel the timeout id and set it null.

misc:

- keep track of multiple eval functio being called by a global lock thingy

setting:

- enable debug logging
- each component adds to default config in getSettingsPanel
    #PoorMansReactSettingsPanel

Advanced mode:

- can change trigger status to be phase 2 in post afk callback
- or, after 1st AFK, in postAFK set another timeout to change status to 3rd.
    set timeout ID in global thingy.
- post unAFK for cleanup

Triggers:

- register     [on start action (register event listener, sub event)]
- cleanup      [on stop action (remove event listener, unsub from event)]
- getSettings  [returns a jsx component that changes that trigger's config, like enabled/disabled]
- selfTest     [test whether this trigger is working and something hasn't been broken]

- class: AFKTrigger 
- class: UnAFKTrigger

Evaluate:

- AFKConditions     (called by event)
- unAFK conditions  (called by event)

GLOBALS.ts:

- timeoutIdArray
- postAFKcallbackArray    
- postunAFKcallbackArray
- 

CallBacks/Hooks

- runs all the callbacks/methods/hooks/functions in the array
- clears the methods from the array after running them.
- can be abstracted into RunHooks class
    - RunPostAFKCallbacks(RunHooks)
    - RunPostunAFKCallbacks(RunHooks)

insides: - callBackArray - addHook() - processHooks() / runCallbacks()

Typescript to try:

  • getting zlib from window rather than argument
  • putting the boilerplate in index
  • having my own class instead