Updated view logic

This commit is contained in:
itdominator 2021-07-27 17:46:56 -05:00
parent 4dafc328a5
commit a7d56bae10
2 changed files with 25 additions and 5 deletions

View File

@ -17,7 +17,10 @@ window_controllers = {}
def get_window_controller():
if session.get('win_controller_id') is None:
controller = None
try:
controller = window_controllers[ session["win_controller_id"] ]
except Exception as e:
id = secrets.token_hex(16)
controller = WindowController()
view = controller.get_window(1).get_view(0)
@ -28,8 +31,9 @@ def get_window_controller():
session['win_controller_id'] = id
window_controllers.update( {id: controller } )
controller = window_controllers[ session["win_controller_id"] ]
return window_controllers[ session["win_controller_id"] ]
return controller
@app.route('/', methods=['GET', 'POST'])
@ -68,6 +72,12 @@ def listFiles(_hash = None):
path = view.get_path_part_from_hash(_hash)
view.push_to_path(path)
error_msg = view.get_error_message()
if error_msg != None:
view.unset_error_message()
return msgHandler.createMessageJSON("danger", error_msg)
sub_path = view.get_current_sub_path()
files = view.get_files_formatted()
fave = db.session.query(Favorites).filter_by(link = sub_path).first()

View File

@ -9,8 +9,8 @@ from os.path import isdir, isfile, join
# Application imports
from . import Path, Settings, Launcher
from .utils import Settings, Launcher
from . import Path
class View(Settings, Launcher, Path):
def __init__(self):
@ -20,6 +20,7 @@ class View(Settings, Launcher, Path):
self.images = []
self.desktop = []
self.ungrouped = []
self.error_message = None
self.set_to_home()
@ -33,7 +34,7 @@ class View(Settings, Launcher, Path):
self.files = []
if not isdir(path):
self.set_to_home()
self._set_error_message("Path can not be accessed.")
return ""
for f in listdir(path):
@ -120,6 +121,15 @@ class View(Settings, Launcher, Path):
return False
def _set_error_message(self, text):
self.error_message = text
def unset_error_message(self):
self.error_message = None
def get_error_message(self):
return self.error_message
def get_current_directory(self):
return self.get_path()