Skip to content

Commit

Permalink
ios: Revert iOS 12 bugfix from v27.202 release
Browse files Browse the repository at this point in the history
This reverts commit f838a35, which fixed the iOS 12 bug #5670.
That bugfix involved a tradeoff: it disabled translation on three
user-facing messages (one being the prominent "X unreads" message in
`UnreadNotice`), replacing them with hard-coded strings in English.

That was an improvement for iOS 12 users, since they were affected
by #5670. But in the previous commit, we cherry-picked our commit
from `main` that enforced our intended iOS 14+ requirement. So,
while iOS 12 users can still get the #5670 fix in the v27.202
release (as the last release available to them), now we can make a
followup release v27.203 that puts the translations back, and won't
clobber iOS 12 users' installs with a version that has the #5670
bug.
  • Loading branch information
chrisbobbe committed Mar 11, 2023
1 parent 3fb3826 commit bb8543b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 28 deletions.
15 changes: 10 additions & 5 deletions src/chat/UnreadNotice.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { Narrow } from '../types';
import { createStyleSheet } from '../styles';
import { useSelector } from '../react-redux';
import { getUnreadCountForNarrow } from '../selectors';
import ZulipText from '../common/ZulipText';
import ZulipTextIntl from '../common/ZulipTextIntl';
import MarkAsReadButton from './MarkAsReadButton';
import AnimatedScaleComponent from '../animation/AnimatedScaleComponent';

Expand Down Expand Up @@ -47,11 +47,16 @@ export default function UnreadNotice(props: Props): Node {
return (
<AnimatedScaleComponent visible={unreadCount > 0} style={styles.unreadContainer}>
<View style={styles.unreadTextWrapper}>
<ZulipText
<ZulipTextIntl
style={styles.unreadText}
text={
unreadCount === 1 ? `${unreadCount} unread message` : `${unreadCount} unread messages`
}
text={{
text: `\
{unreadCount, plural,
one {{unreadCount} unread message}
other {{unreadCount} unread messages}
}`,
values: { unreadCount },
}}
/>
</View>
<MarkAsReadButton narrow={narrow} />
Expand Down
27 changes: 20 additions & 7 deletions src/message/ReadReceiptsScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { View, FlatList } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';

import useFetchedDataWithRefresh from '../common/useFetchedDataWithRefresh';
import ZulipText from '../common/ZulipText';
import ZulipTextIntl from '../common/ZulipTextIntl';
import { useGlobalSelector, useSelector } from '../react-redux';
import * as api from '../api';
import type { AppNavigationProp } from '../nav/AppNavigator';
Expand All @@ -22,6 +22,7 @@ import type { UserId } from '../api/idTypes';
import { getGlobalSettings } from '../directSelectors';
import type { UserOrBot } from '../api/modelTypes';
import LoadingIndicator from '../common/LoadingIndicator';
import WebLink from '../common/WebLink';
import { createStyleSheet } from '../styles';

type Props = $ReadOnly<{|
Expand Down Expand Up @@ -122,14 +123,26 @@ export default function ReadReceiptsScreen(props: Props): Node {
[onPressUser],
);

const summaryText = useMemo(
const localizableSummaryText = useMemo(
() =>
displayUserIds.length > 0
? displayUserIds.length === 1
? `This message has been read by ${displayUserIds.length} person:`
: `This message has been read by ${displayUserIds.length} people:`
? {
// This is actually the same string as in the web app; see where
// that's set in static/js/read_receipts.js
text: `\
{num_of_people, plural,
one {This message has been <z-link>read</z-link> by {num_of_people} person:}
other {This message has been <z-link>read</z-link> by {num_of_people} people:}\
}`,
values: {
num_of_people: displayUserIds.length,
'z-link': chunks => (
<WebLink url={new URL('/help/read-receipts', auth.realm)}>{chunks}</WebLink>
),
},
}
: 'No one has read this message yet.',
[displayUserIds.length],
[auth.realm, displayUserIds.length],
);

const styles = useMemo(
Expand All @@ -146,7 +159,7 @@ export default function ReadReceiptsScreen(props: Props): Node {
{latestSuccessResult ? (
<View style={styles.flex1}>
<SafeAreaView mode="padding" edges={['right', 'left']} style={styles.summaryTextWrapper}>
<ZulipText text={summaryText} />
<ZulipTextIntl text={localizableSummaryText} />
</SafeAreaView>
<FlatList style={styles.flex1} data={displayUserIds} renderItem={renderItem} />
</View>
Expand Down
13 changes: 6 additions & 7 deletions src/settings/NotificationsScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,12 @@ export default function NotificationsScreen(props: Props): Node {
? {
icon: { Component: IconAlertTriangle, color: kWarningColor },
subtitle: {
text: '{_}',
values: {
_:
problemAccountsCount === 1
? `Notifications for ${problemAccountsCount} other logged-in account may not arrive.`
: `Notifications for ${problemAccountsCount} other logged-in accounts may not arrive.`,
},
text: `\
{problemAccountsCount, plural,
one {Notifications for {problemAccountsCount} other logged-in account may not arrive.}
other {Notifications for {problemAccountsCount} other logged-in accounts may not arrive.}
}`,
values: { problemAccountsCount },
},
}
: undefined;
Expand Down
10 changes: 1 addition & 9 deletions tools/check-messages-en
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,10 @@ function main() {

const possibleUiStrings = getPossibleUiStrings(getPossibleUiStringFilePaths());

const ignoreDanglingMessageIds = new Set([
// Just for the cherry-pick release v27.202, we removed these messages
// from the UI component tree; let them dangle.
'{num_of_people, plural,\n one {This message has been <z-link>read</z-link> by {num_of_people} person:}\n other {This message has been <z-link>read</z-link> by {num_of_people} people:}}',
'{problemAccountsCount, plural,\n one {Notifications for {problemAccountsCount} other logged-in account may not arrive.}\n other {Notifications for {problemAccountsCount} other logged-in accounts may not arrive.}\n}',
'{unreadCount, plural,\n one {{unreadCount} unread message}\n other {{unreadCount} unread messages}\n}',
]);

// Check each key ("message ID" in formatjs's lingo) against
// possibleUiStrings, and make a list of any that aren't found.
const danglingMessageIds = Object.keys(messages_en).filter(
messageId => !possibleUiStrings.has(messageId) && !ignoreDanglingMessageIds.has(messageId),
messageId => !possibleUiStrings.has(messageId),
);

if (danglingMessageIds.length > 0) {
Expand Down

0 comments on commit bb8543b

Please sign in to comment.