therealsujitk / flarum-ext-gifs

A Flarum extension that integrates your forum with GIF search engines.
https://discuss.flarum.org/d/23101
MIT License
5 stars 8 forks source link

Use default values when settings aren't in the database #15

Closed therealsujitk closed 3 years ago

therealsujitk commented 3 years ago

Flarum only saves settings in the database that have been changed, hence the default values aren't saved in the database. When settings aren't saved in the database, a default value needs to be used in the oninit() function. For example

this.engine = app.forum.attribute(`${prefix}.engine`);

needs to be changed to

this.engine = app.forum.attribute(`${prefix}.engine`) || 'giphy';

Temporary Fix

Simply change the setting in the admin panel to a different value and save it so that Flarum understands a change has been made and needs to be updated. You can change it back to it's previous value and save it again.