fix(core): do not send ButtonRequest on every paging event

partial revert of 54db2291f2 from #1671
pull/1696/head
matejcik 3 years ago
parent 8ed7bdbc27
commit 1e1963f1ee

@ -47,11 +47,6 @@ message Failure {
message ButtonRequest {
optional ButtonRequestType code = 1; // enum identifier of the screen
optional uint32 pages = 2; // if the screen is paginated, number of pages
optional uint32 page_number = 3; // if the screen is paginated, current page (1-based)
/* Rationale: both fields are optional, and neither field can have 0 as a valid
value. So both testing `if pages` and `if page_number` do the right thing.
Also the following is always true: `page_is_last = (page_number == pages)` */
/**
* Type of button request
*/

@ -7,7 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## 2.4.1 [14th July 2021]
### Added
- ButtonRequest is sent also after every screen of a multi-page view. [#1671]
- ButtonRequest for multi-page views contains number of pages. [#1671]
### Changed
- Converted altcoin apps to common layout code. [#1538]

@ -283,14 +283,12 @@ if TYPE_CHECKING:
class ButtonRequest(protobuf.MessageType):
code: ButtonRequestType | None
pages: int | None
page_number: int | None
def __init__(
self,
*,
code: ButtonRequestType | None = None,
pages: int | None = None,
page_number: int | None = None,
) -> None:
pass

@ -111,12 +111,9 @@ class Paginated(ui.Layout):
code: ButtonRequestType = ButtonRequestType.Other,
) -> Any:
workflow.close_others()
await ctx.call(ButtonRequest(code=code, pages=len(self.pages)), ButtonAck)
result = WAS_PAGED
while result is WAS_PAGED:
br = ButtonRequest(
code=code, pages=len(self.pages), page_number=self.page + 1
)
await ctx.call(br, ButtonAck)
result = await self
return result

@ -701,7 +701,6 @@ class ButtonRequest(protobuf.MessageType):
FIELDS = {
1: protobuf.Field("code", ButtonRequestType, repeated=False, required=False),
2: protobuf.Field("pages", "uint32", repeated=False, required=False),
3: protobuf.Field("page_number", "uint32", repeated=False, required=False),
}
def __init__(
@ -709,11 +708,9 @@ class ButtonRequest(protobuf.MessageType):
*,
code: Optional[ButtonRequestType] = None,
pages: Optional[int] = None,
page_number: Optional[int] = None,
) -> None:
self.code = code
self.pages = pages
self.page_number = page_number
class ButtonAck(protobuf.MessageType):

Loading…
Cancel
Save