diff --git a/commands.py b/commands.py index 9aef21c..d9999c0 100644 --- a/commands.py +++ b/commands.py @@ -8,7 +8,7 @@ from ._config import CONFIG from .lib.core import GlobalStorage, sync_once -from .lib.gui import close_view, on_note_changed, open_view, show_message, show_quick_panel +from .lib.gui import QuickPanelPlaceholder, close_view, on_note_changed, open_view, show_message, show_quick_panel from .lib.models import Note from .lib.operations import NoteCreator, NoteDeleter, NotesIndicator, NoteUpdater, OperationManager @@ -146,7 +146,7 @@ def callback(self, updated_notes: List[Note]): ) first_sync = sync_times == 0 if first_sync: - show_quick_panel(first_sync) + show_quick_panel(QuickPanelPlaceholder.FIRST_SYNC) global_storage.optimistic_update(CONFIG.SIMPLENOTE_SYNC_TIMES_KEY, sync_times + 1) global_storage.optimistic_update(CONFIG.SIMPLENOTE_STARTED_KEY, False) diff --git a/lib/gui.py b/lib/gui.py index b26bd9d..41f92fa 100644 --- a/lib/gui.py +++ b/lib/gui.py @@ -21,6 +21,7 @@ "close_view", "clear_orphaned_filepaths", "on_note_changed", + "QuickPanelPlaceholder", "show_quick_panel", ] @@ -137,7 +138,15 @@ def on_select(list__modificationDate: List[float], selected_index: int): view = open_view(filepath) -def show_quick_panel(first_sync: bool = False): +from enum import Enum + + +class QuickPanelPlaceholder(str, Enum): + DEFAULT = "Select Note press key 'enter' to open" + FIRST_SYNC = "Sync complete. Press [super+shift+s] [super+shift+l] to display the note list again." + + +def show_quick_panel(placeholder: str = QuickPanelPlaceholder.DEFAULT): if Note.tree.count <= 0: show_message( "No notes found. Please wait for the synchronization to complete, or press [super+shift+s, super+shift+c] to create a note." @@ -157,10 +166,6 @@ def show_quick_panel(first_sync: bool = False): # TODO: Maybe doesn't need to run every time clear_orphaned_filepaths(list__filename) - placeholder = "Select Note press key 'enter' to open" - if first_sync: - placeholder = "Sync complete. Press [super+shift+s] [super+shift+l] to display the note list again." - def show_panel(): sublime.active_window().show_quick_panel( list__title,