Skip to content

Commit

Permalink
fix: set suggestion to both-sides on ngram created
Browse files Browse the repository at this point in the history
  • Loading branch information
Crissium committed Oct 14, 2023
1 parent 6070c5d commit 8693d05
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions server/app/api/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,7 @@ def num_suggestions() -> 'Response':
def create_ngram_table() -> 'Response':
db_manager.create_ngram_table()
logger.info('Recreated ngram table')
dicts = current_app.extensions['dictionaries']
dicts.settings.change_suggestions_mode_from_right_side_to_both_sides()
response = jsonify({'success': True})
return response
8 changes: 8 additions & 0 deletions server/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ def _save_history(self) -> 'None':
def _save_misc_configs(self) -> 'None':
self._save_settings_to_file(self.misc_configs, self.MISC_CONFIGS_FILE)

def change_suggestions_mode_from_right_side_to_both_sides(self) -> 'None':
self.preferences['suggestions_mode'] = 'both-sides'
with open(self.PREFERENCES_FILE) as preferences_file:
preferences = preferences_file.read()
preferences = preferences.replace('suggestions_mode: right-side', '# suggestions_mode: right-side').replace('# suggestions_mode: both-sides', 'suggestions_mode: both-sides')
with open(self.PREFERENCES_FILE, 'w') as preferences_file:
preferences_file.write(preferences)

def __init__(self) -> 'None':
if not os.path.isfile(self.PREFERENCES_FILE):
with open(self.PREFERENCES_FILE, 'w') as preferences_file:
Expand Down

0 comments on commit 8693d05

Please sign in to comment.