Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gui: can't scroll down after click 'play all' button #655

Merged
merged 5 commits into from
Mar 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
apply yapf
  • Loading branch information
cosven committed Mar 4, 2023
commit 1fa846d5745c5edc9c42ea147c33217c334b63aa
24 changes: 16 additions & 8 deletions feeluown/utils/reader.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import logging
from abc import ABCMeta, abstractmethod
from typing import (
List, Generic, TypeVar, Optional, Callable, Tuple,
Iterable, cast, Sequence, AsyncIterable,
List,
Generic,
TypeVar,
Optional,
Callable,
Tuple,
Iterable,
cast,
Sequence,
AsyncIterable,
)


logger = logging.getLogger(__name__)

__all__ = (
Expand All @@ -19,7 +26,6 @@
'wrap',
)


T = TypeVar("T")


Expand Down Expand Up @@ -176,6 +182,7 @@ def _read_next(self) -> T:


class RandomSequentialReader(Reader[T]):

def __init__(self,
count,
read_func: Callable[[int, int], Iterable[T]],
Expand Down Expand Up @@ -243,7 +250,7 @@ def _read_range(self, start, end):
logger.debug('trigger read_func(%d, %d)', start, end)
objs = list(self._read_func(start, end))
actual = len(objs)
self._objects[start:start+actual] = objs
self._objects[start:start + actual] = objs
self._refresh_ranges()

def _has_index(self, index):
Expand Down Expand Up @@ -316,6 +323,7 @@ class AsyncReader:


class AsyncSequentialReader(AsyncReader):

def __init__(self, g, count, offset=0):
"""init

Expand Down Expand Up @@ -380,9 +388,9 @@ def wrap(iterable):
raise TypeError(f'must be a Iterable, got {type(iterable)}')
if isinstance(iterable, Sequence):
count = len(iterable)
return RandomSequentialReader(
count, lambda start, end: iterable[start:end], max_per_read=max(count, 1)
)
return RandomSequentialReader(count,
lambda start, end: iterable[start:end],
max_per_read=max(count, 1))
# maybe a generator/iterator
return SequentialReader(iterable, count=None)

Expand Down