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

Session timeout notification incorrectly says "Days" on iOS #7510

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 17 additions & 3 deletions app/utils/notification/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,26 @@

export const scheduleExpiredNotification = (serverUrl: string, session: Session, serverName: string, locale = DEFAULT_LOCALE) => {
const expiresAt = session?.expires_at || 0;
const expiresInDays = Math.ceil(Math.abs(moment.duration(moment().diff(moment(expiresAt))).asDays()));
const expiresInHours = Math.ceil(Math.abs(moment.duration(moment().diff(moment(expiresAt))).asHours()));
const expiresInDays = Math.floor(expiresInHours / 24); // Calculate expiresInDays
const remainingHours = expiresInHours % 24; // Calculate remaining hours
const intl = createIntl({locale, messages: getTranslations(locale)});

Check failure on line 97 in app/utils/notification/index.ts

View workflow job for this annotation

GitHub Actions / test

Trailing spaces not allowed
const daysPlural = intl.formatPlural(expiresInDays, {
one: 'day',
other: 'days',
});

const hoursPlural = intl.formatPlural(remainingHours, {
one: 'hour',
other: 'hours',
});

const body = intl.formatMessage({
id: 'mobile.session_expired',
defaultMessage: 'Please log in to continue receiving notifications. Sessions for {siteName} are configured to expire every {daysCount, number} {daysCount, plural, one {day} other {days}}.',
}, {siteName: serverName, daysCount: expiresInDays});
defaultMessage: 'Please log in to continue receiving notifications. Sessions for {siteName} are configured to expire in {daysCount, number} {days} and {hoursCount, number} {hours}.', // Update the message
Copy link
Contributor

Choose a reason for hiding this comment

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

@esethna can you please advice on the message that we should use for hours and days ?

Copy link
Contributor

Choose a reason for hiding this comment

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

We probably also need to remove the whole days part if the number of days is 0.

}, {siteName: serverName, daysCount: expiresInDays, days: daysPlural, hoursCount: remainingHours, hours: hoursPlural});

const title = intl.formatMessage({id: 'mobile.session_expired.title', defaultMessage: 'Session Expired'});

if (expiresAt) {
Expand Down
4 changes: 2 additions & 2 deletions assets/base/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -678,10 +678,10 @@
"mobile.search.modifier.from": "a specific user",
"mobile.search.modifier.in": "a specific channel",
"mobile.search.modifier.phrases": "messages with phrases",
"mobile.search.results": "{count} search {count, plural, one {result} other {results}}",
"mobile.search.show_less": "Show less",
"mobile.search.show_more": "Show more",
"mobile.search.team.select": "Select a team to search",
"mobile.search.results": "{count} search {count, plural, one {result} other {results}}",
"mobile.server_identifier.exists": "You are already connected to this server.",
"mobile.server_link.error.text": "The link could not be found on this server.",
"mobile.server_link.error.title": "Link Error",
Expand Down Expand Up @@ -1068,4 +1068,4 @@
"video.download_description": "This video must be downloaded to play it.",
"video.failed_description": "An error occurred while trying to play the video.",
"your.servers": "Your servers"
}
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading