handle theme deletion
This commit is contained in:
parent
7a1b408e26
commit
156ab7f1fd
|
@ -68,7 +68,7 @@
|
|||
-else
|
||||
%a.grid-item.button.activate onclick='toggle_theme("{{theme.hash}}")' << Enable
|
||||
|
||||
%a.grid-item.button href='delete_item("/preferences/theme/delete", "{{theme.hash}}")' << Delete
|
||||
%a.grid-item.button onclick='delete_item("/preferences/theme/delete", "{{theme.hash}}")' << Delete
|
||||
|
||||
%details.category.section {{'open' if pass_type == 'bitwarden' else ''}}
|
||||
%summary << Password Storage: Bitwarden
|
||||
|
|
|
@ -510,6 +510,20 @@ def preferences_bw_unlock(handler, request, password):
|
|||
return request.ok_or_redirect('Unlocked password vault')
|
||||
|
||||
|
||||
@Local.route('/preferences/theme/delete/{hash}')
|
||||
def preferences_theme_delete(handler, request, hash):
|
||||
themes = handler.window.themes
|
||||
|
||||
try:
|
||||
theme = themes.user[hash]
|
||||
|
||||
except KeyError as e:
|
||||
request.error(e, 404)
|
||||
|
||||
theme.path.delete()
|
||||
return request.ok_or_redirect(f'Deleted theme: {theme.name}')
|
||||
|
||||
|
||||
@Local.route('/preferences/theme/set/{hash}')
|
||||
def preferences_theme_set(handler, request, hash):
|
||||
themes = handler.window.themes
|
||||
|
|
|
@ -390,13 +390,18 @@ class UserWatchHandler(WatcherBase):
|
|||
|
||||
def on_deleted(self, event):
|
||||
path = Path(event.src_path)
|
||||
theme = self.themes.get_theme_by_file(path)
|
||||
|
||||
try:
|
||||
theme = self.themes.get_theme_by_file(path)
|
||||
|
||||
except KeyError:
|
||||
return
|
||||
|
||||
if path.name == 'manifest.ini':
|
||||
if self.themes.current == theme.path:
|
||||
if self.themes.current == theme.hash:
|
||||
run_in_gui_thread(self.themes.unset)
|
||||
|
||||
del self.themes.user[theme.path]
|
||||
del self.themes.user[theme.hash]
|
||||
|
||||
logging.verbose(f'Deleted theme: {theme.name}')
|
||||
|
||||
|
|
Reference in a new issue