Fixed: can't close app normally if first time setup fails

This commit is contained in:
jeffser 2024-05-19 12:33:24 -06:00
parent adef5b5671
commit f6cc6ac894

View File

@ -37,6 +37,7 @@ class AlpacaWindow(Adw.ApplicationWindow):
local_models = []
chats = {"chats": {"New Chat": {"messages": []}}, "selected_chat": "New Chat"}
attached_image = {"path": None, "base64": None}
first_time_setup = False
#Elements
shortcut_window : Gtk.ShortcutsWindow = Gtk.Template.Child()
@ -578,12 +579,13 @@ class AlpacaWindow(Adw.ApplicationWindow):
def closing_connection_dialog(self, dialog):
if self.ollama_url is None: self.destroy()
if self.ollama_url is None or self.first_time_setup: self.destroy()
if self.ollama_url == self.connection_url_entry.get_text():
self.connection_dialog.force_close()
if self.ollama_url is None or self.verify_connection() == False:
self.show_connection_dialog(True)
self.show_toast("error", 1, self.connection_overlay)
else: self.first_time_setup = False
return
dialog = Adw.AlertDialog(
heading=f"Save Changes?",
@ -812,5 +814,7 @@ class AlpacaWindow(Adw.ApplicationWindow):
with open(os.path.join(self.config_dir, "server.conf"), "r") as f:
self.ollama_url = f.read()
if self.verify_connection() is False: self.show_connection_dialog(True)
else: self.connection_dialog.present(self)
else:
self.first_time_setup = True
self.connection_dialog.present(self)
self.update_chat_list()