CMorooney / obsidian-game-search-plugin

Obsidian plugin that automatically creates notes by searching for video games
MIT License
36 stars 10 forks source link

Re-initialize the RAWG API when saving settings #21

Closed breakid closed 7 months ago

breakid commented 7 months ago

Problem: The rawgAPI was only set when the plugin initially loaded. A user could enter their API key on the settings page, but the plugin wouldn't start using the API key until the plugin was reloaded (e.g., when the user closed and re-opened Obsidian). I believe this to be the most likely cause of the 401 errors that would seemingly resolve in time.

Solution: Added a line to the saveSettings() function that re-initializes the API, thus immediately picking up on changes to the API key.

Testing:

CMorooney commented 7 months ago

hah! good catch, I feel a little silly for missing it all this time

the PR, explanation, and README update is much appreciated!