Skip to content

Commit

Permalink
Remove previous button in case of single file directory
Browse files Browse the repository at this point in the history
Make sure previous doesn't overlap with last item in directory
  • Loading branch information
dormant-user committed Feb 4, 2024
1 parent 9fe72b2 commit cdf9e12
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pystream/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def parse_authorization(cls, value: Any) -> Dict[str, SecretStr]:
raise ValueError("input should be a valid dictionary with username as key and password as value")
r = {}
for k, v in val.items():
if len(k) < 3:
if len(k) < 4:
raise ValueError(f"[{k}: {v}] username should be at least 4 or more characters")
if len(v) < 8:
raise ValueError(f"[{k}: {v}] password should be at least 8 or more characters")
Expand Down
11 changes: 8 additions & 3 deletions pystream/models/squire.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,14 @@ def get_iter(filename: pathlib.PurePath) -> Union[Tuple[str, str], Tuple[None, N
key=lambda x: natural_sort_key(x)
)
idx = dir_content.index(filename.name)
try:
previous_ = dir_content[idx - 1]
except IndexError:
if idx > 0: # 0-1 is -1, which will in turn fetch the last item from the list instead of leaving it blank
try:
previous_ = dir_content[idx - 1]
if previous_ == filename.name: # This should be covered by > 0, but double check as a safety net
previous_ = None
except IndexError:
previous_ = None
else:
previous_ = None
try:
next_ = dir_content[idx + 1]
Expand Down

0 comments on commit cdf9e12

Please sign in to comment.