|
1 | 1 | from tkinter import messagebox |
2 | 2 | from ui.utils import * |
3 | | -from logic.get_user import check_if_contact_exists |
| 3 | +from logic.user import validate_identifier |
4 | 4 | from logic.contacts import save_contact |
5 | 5 | from logic.storage import save_account_data |
6 | 6 | import tkinter as tk |
@@ -51,18 +51,14 @@ def add_contact(self): |
51 | 51 | self.status.config(text="You cannot add yourself", fg="red") |
52 | 52 | return |
53 | 53 |
|
54 | | - try: |
55 | | - # if not check_if_contact_exists(self.master.user_data, self.master.user_data_lock, contact_id): |
56 | | - # logger.error("[BUG] This should never execute, because the server should return a 40X error code and that should cause an exception..") |
57 | | - # return |
58 | | - |
59 | | - save_contact(self.master.user_data, self.master.user_data_lock, contact_id) |
60 | | - save_account_data(self.master.user_data, self.master.user_data_lock) |
61 | | - except ValueError as e: |
62 | | - self.status.config(text=e, fg="red") |
63 | | - logger.error("Error occured while adding new contact (%s): %s ", contact_id, e) |
| 54 | + if not validate_identifier(contact_id): |
| 55 | + logger.debug("Identifier is invalid.") |
| 56 | + self.status.config(text = "Invalid identifier", fg="red") |
64 | 57 | return |
65 | | - |
| 58 | + |
| 59 | + save_contact(self.master.user_data, self.master.user_data_lock, contact_id) |
| 60 | + save_account_data(self.master.user_data, self.master.user_data_lock) |
| 61 | + |
66 | 62 |
|
67 | 63 | self.master.new_contact(contact_id) |
68 | 64 | self.destroy() |
|
0 commit comments