Skip to content

Commit

Permalink
Merge pull request #55 from RedAtman/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
RedAtman authored Jul 31, 2024
2 parents 955be8a + 60dbb1b commit f535593
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 32 deletions.
13 changes: 0 additions & 13 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,6 @@
]


# def init_settings(reload_if_needed: Optional(Callable) = None):
# global SETTINGS
# if SETTINGS is None:
# SETTINGS = sublime.load_settings("SIMPLENOTE_SETTINGS_FILE")
# # logger.debug(("SETTINGS.__dict__: ", SETTINGS.__dict__))
# # logger.debug(("SETTINGS.username: ", SETTINGS.get("username")))
# if reload_if_needed:
# SETTINGS.clear_on_change("username")
# SETTINGS.clear_on_change("password")
# SETTINGS.add_on_change("username", reload_if_needed)
# SETTINGS.add_on_change("password", reload_if_needed)


def edit_settings():
# sublime.run_command("open_file", {"file": CONFIG.SIMPLENOTE_SETTINGS_FILE_PATH})
sublime.run_command(
Expand Down
19 changes: 5 additions & 14 deletions operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

import sublime

from ._config import CONFIG
from .gui import _show_message, open_view, remove_status
from .gui import _show_message, edit_settings, remove_status
from .models import Note
from .utils.patterns.singleton.base import Singleton

Expand Down Expand Up @@ -53,6 +52,10 @@ def join(self):
self.exception_callback(self.result)
else:
logger.debug(str(self.result))
if isinstance(self.result, Exception):
logger.exception(self.result)
sublime.message_dialog(str(self.result))
edit_settings()


class NotesIndicator(Operation):
Expand All @@ -66,9 +69,6 @@ def run(self):
result: List[Note] = Note.index(limit=self.sync_note_number, data=True)
self.result = result
except Exception as err:
logger.exception(err)
sublime.message_dialog(str(err))
open_view(CONFIG.SIMPLENOTE_SETTINGS_FILE_PATH)
self.result = err


Expand All @@ -80,9 +80,6 @@ def run(self):
note.create()
self.result = note
except Exception as err:
logger.exception(err)
sublime.message_dialog(str(err))
open_view(CONFIG.SIMPLENOTE_SETTINGS_FILE_PATH)
self.result = err


Expand All @@ -98,9 +95,6 @@ def run(self):
note: Note = self.note.modify()
self.result = note
except Exception as err:
logger.exception(err)
sublime.message_dialog(str(err))
open_view(CONFIG.SIMPLENOTE_SETTINGS_FILE_PATH)
self.result = err


Expand All @@ -115,9 +109,6 @@ def run(self):
self.note.trash()
self.result = self.note
except Exception as err:
logger.exception(err)
sublime.message_dialog(str(err))
open_view(CONFIG.SIMPLENOTE_SETTINGS_FILE_PATH)
self.result = err


Expand Down
11 changes: 6 additions & 5 deletions simplenotecommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,14 @@ def reload_if_needed():

def plugin_loaded():
# load_notes()
logger.debug(("Loaded notes number: ", len(Note.mapper_id_note)))
logger.debug(("Loaded notes number: ", Note.tree.count))

settings = sublime.load_settings(CONFIG.SIMPLENOTE_SETTINGS_FILE_PATH)
# logger.debug(("SETTINGS.__dict__: ", SETTINGS.__dict__))
# logger.debug(("SETTINGS.username: ", SETTINGS.get("username")))
# SETTINGS.clear_on_change("username")
# SETTINGS.clear_on_change("password")
# SETTINGS.add_on_change("username", reload_if_needed)
# SETTINGS.add_on_change("password", reload_if_needed)
settings.clear_on_change("username")
settings.clear_on_change("password")
settings.add_on_change("username", reload_if_needed)
settings.add_on_change("password", reload_if_needed)

reload_if_needed()

0 comments on commit f535593

Please sign in to comment.