Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextReplace: Use settings.json for storing rules instead of DataStore API #1767

Closed
wants to merge 7 commits into from

Conversation

HeLau1337
Copy link

@HeLau1337 HeLau1337 commented Sep 30, 2023

The changes of this PR change the way the existing TextReplace plugin stores the rules (find, replace). It uses the settings.store (aka. the settings.json file in the AppData directory) instead of Vencord's DataStore API (aka. the IndexedDB of Chromium).

Using the settings.json would have a few benefits imo:

  • rules could be synced with Vencord Cloud Sync
  • users can edit their rules in the settings.json directly using any text editor (which is a blessing if you want to edit a lot of rules or copy/paste them)
  • sharing an entire set of rules with other users would be easier, too

I'm not aware of potential drawbacks. Let me know what you think about it.

image

@lillithkt
Copy link
Contributor

use settings.store instead of vencord.settings.plugins

regexRules = await DataStore.get(REGEX_RULES_KEY) ?? makeEmptyRuleArray();
getRulesFromSettingsJson();
if (!("rules" in Vencord.Settings.plugins[PLUGIN_NAME])) {
// If the "rules" key doesn't exist in the settings.json yet, create it at startup so users can directly start defining their rules in the settings.json using a blank template.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would have to be changed relatively soon

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, what exactly are you referring to? And does it still apply to the current state of the code (I pushed changes)?

@HeLau1337
Copy link
Author

use settings.store instead of vencord.settings.plugins

Oops, will fix that, thanks for letting me know!

@lillithkt
Copy link
Contributor

also

new rule if you update a plugin that has no readme you are legally obligated to write one

  • vee

@lillithkt
Copy link
Contributor

optimally this rewrite should wait on #696

@lillithkt
Copy link
Contributor

also this is already implimented in #696 by the looks of it.

the example impl is a TextReplace plugin

…tead of Vencord.settings.plugins... (that was stupid, sorry)
@HeLau1337
Copy link
Author

I was told that my idea was suggested before and got declined: #540 (comment)

The Discord user vending.machine also made me aware of the drawbacks:

settings.json is a very inefficient storage
it's blocking & json is inherently kinda shit
it's also stored in localStorage in browsers which is potentially limited to a few kb
DataStore/indexeddb is much more efficient, not blocking (async) and has no storage limit
settings should only be used for basic booleans and small data. text replace rules can potentially become plenty and large storing them in settings is bad

@HeLau1337 HeLau1337 closed this Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants