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

feat: [IOCOM-1391] Flag to enable Messages Home with the new DS #5766

Merged
merged 12 commits into from
May 15, 2024

Conversation

Vangaorth
Copy link
Contributor

Short description

This PR adds a persisted preference to display the Messages Home with the new DS.

Profile New WiP Home
Simulator Screenshot - iPhone 15 - 2024-05-13 at 16 39 15 Simulator Screenshot - iPhone 15 - 2024-05-13 at 16 39 08

List of changes proposed in this pull request

  • New isNewHomeSectionEnabled property on persistedPreferences, with its migration
  • DeveloperModeSection component has a new switch to control such property value
  • TabNavigator spawns either the Legacy or the new MessagesHomeScreen
  • Old MessagesHomeScreen renamed to LegacyMessagesHomeScreen

How to test

Using the io-dev-api-server, check that both the new and the old messages home screen is displayed, when the related toggle is changed in the debug profile options.

@pagopa-github-bot
Copy link
Collaborator

pagopa-github-bot commented May 13, 2024

Affected stories

  • 🌟 IOCOM-1391: [App] Rimuovere selettori inutilizzati nel reducer di messageStatus
    subtask of

Generated by 🚫 dangerJS against c5293cf

Copy link

codecov bot commented May 13, 2024

Codecov Report

Attention: Patch coverage is 48.21429% with 29 lines in your changes are missing coverage. Please review.

Project coverage is 49.54%. Comparing base (4f204b4) to head (c5293cf).
Report is 78 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5766      +/-   ##
==========================================
+ Coverage   48.42%   49.54%   +1.12%     
==========================================
  Files        1488     1604     +116     
  Lines       31617    31869     +252     
  Branches     7669     7702      +33     
==========================================
+ Hits        15311    15790     +479     
+ Misses      16238    16016     -222     
+ Partials       68       63       -5     
Files Coverage Δ
...features/messages/store/reducers/messagesStatus.ts 63.15% <ø> (+25.90%) ⬆️
ts/store/actions/persistedPreferences.ts 100.00% <100.00%> (ø)
...s/features/messages/screens/MessagesHomeScreen.tsx 66.66% <66.66%> (+13.00%) ⬆️
ts/store/reducers/persistedPreferences.ts 68.18% <50.00%> (-1.18%) ⬇️
ts/screens/profile/DeveloperModeSection.tsx 4.37% <0.00%> (-0.10%) ⬇️
ts/navigation/TabNavigator.tsx 9.09% <0.00%> (-1.72%) ⬇️
...ures/messages/screens/LegacyMessagesHomeScreen.tsx 53.65% <53.65%> (ø)

... and 416 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6b512bf...c5293cf. Read the comment docs.

# Conflicts:
#	ts/features/messages/screens/MessagesHomeScreen.tsx
Copy link
Contributor

@LazyAfternoons LazyAfternoons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we also removing unused selectors in messagesStatus.ts as part of this PR? Could you please create a ticket to address this issue? If it doesn't fit into any specific stream board, you might use our cross board if that makes sense to you.

@Vangaorth Vangaorth changed the title [chore] Flag to enable Messages Home with the new DS [chore, IOCOM-1391] Flag to enable Messages Home with the new DS May 15, 2024
@Vangaorth
Copy link
Contributor Author

Are we also removing unused selectors in messagesStatus.ts as part of this PR? Could you please create a ticket to address this issue? If it doesn't fit into any specific stream board, you might use our cross board if that makes sense to you.

Linked using the title

@LazyAfternoons LazyAfternoons changed the title [chore, IOCOM-1391] Flag to enable Messages Home with the new DS [IOCOM-1391] Flag to enable Messages Home with the new DS May 15, 2024
@pagopa-github-bot pagopa-github-bot changed the title [IOCOM-1391] Flag to enable Messages Home with the new DS feat: [IOCOM-1391] Flag to enable Messages Home with the new DS May 15, 2024
Copy link
Contributor

@LazyAfternoons LazyAfternoons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Vangaorth Vangaorth merged commit fdca533 into master May 15, 2024
13 checks passed
@Vangaorth Vangaorth deleted the feature/homeSwitch branch May 15, 2024 20:11
Vangaorth added a commit that referenced this pull request May 17, 2024
…sages' Home (#5770)

⚠️ This PR depends on #5766 ⚠️

## Short description
This PR adds the Chip behaviour to the new DS Messages' Home.
|Inbox|Archived|
|-|-|
|![Simulator Screenshot - iPhone 15 - 2024-05-15 at 14 50
34](https://github.com/pagopa/io-app/assets/5150343/9164fd98-6cff-4087-8f0e-5e10f6144d3a)|![Simulator
Screenshot - iPhone 15 - 2024-05-15 at 14 50
37](https://github.com/pagopa/io-app/assets/5150343/59ede441-3b3d-4888-8e80-cb835dcdae89)|

## List of changes proposed in this pull request
New Messages Home is organised as follows:
```
MessagesHome
\_TabNavigationContainer
  \_InboxTab
  \_ArchivedTab
\_ViewPagerContainer
   \_MessageList // Inbox
   \_MessageList // Archive
```
The major challenge is to avoid unnecessary re-renderings in the
components included by the`ViewPager`. In order to do so, the shown
category (inbox or archive) is stored into redux
(`ts/features/messages/store/reducers/allPaginated.ts`), inside the
`allPaginated` state (which is not persisted) as a literal which value
can be either `inbox` or `archive`. Named `shownCategory`, its value can
be retrieved using a selector (`shownMessageCategorySelector`).

The `TabNavigationContainer` component uses such value in order to
display the selected tab. On every change, it re-renders itself. On a
press event, it dispatches an action to trigger the change into redux
and it also instructs the `ViewPager` component to scroll to the desired
page. This is necessary since the `ViewPager` does not have a method to
show the current page based on a changing value (i.e., it needs to be
done programmatically). A guard prevents the event logic to be fired if
the already selected Tab is pressed.

The `ViewPagerContainer` shows the Inbox and Archive message lists using
the new `MessageList` component (and specialising it by assigning the
proper category). Since there are only two pages, both instances of
`MessageList` are rendered upon first ViewPagerContainer loading. In
order to avoid unnecessary re-renderings when the user scrolls
horizontally between the pages, the underlying `ViewPager` uses the
`onPageSelected` event to dispatch the redux action that updates the
`shownCategory`. This triggers the re-rendering of
`TabNavigationContainer`, keeping the UI aligned. This event is
triggered only when the page changes (i.e., there is no need for a
"same-page" guard like in `TabNavigationContainer`).

Finally, the logic that triggers the first message loading is placed
inside the `TabNavigationContainer`, since it is the only component that
can use an `useEffect` hook that triggers every time the screen changes.
Loading is fired only if the related message section pot (inbox or
archived) is `pot.none`.

As a last note, this PR also moves legacy messages' screens and legacy
messages home's components into related `legacy` folders.

## How to test
Enable both new DS and new Messages' Home (from Profile). Check that:
- tap on a Chip switches both Chip and View Pager
- slide on the View Pager switches both View Pager and Chip
- upon first full displaying of each inbox and archive screens, a
`reloadAllMessage.request` should be fired (but no more afterwards)
- check that the only component that re-renders itself multiple times is
`TabNavigationContainer`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants