diff --git a/src/__tests__/lib/exampleData.js b/src/__tests__/lib/exampleData.js index abc22401009..b94b276791f 100644 --- a/src/__tests__/lib/exampleData.js +++ b/src/__tests__/lib/exampleData.js @@ -21,7 +21,7 @@ import { randString, randInt } from '../../utils/misc'; import { makeUserId } from '../../api/idTypes'; import type { InitialData } from '../../api/apiTypes'; import { EventTypes, type UpdateMessageEvent } from '../../api/eventTypes'; -import { CreateWebPublicStreamPolicy, EmailAddressVisibility } from '../../api/permissionsTypes'; +import { CreateWebPublicStreamPolicy } from '../../api/permissionsTypes'; import type { AccountSwitchAction, LoginSuccessAction, @@ -784,7 +784,6 @@ export const action = Object.freeze({ realm_digest_weekday: 2, realm_disallow_disposable_email_addresses: true, realm_edit_topic_policy: 3, - realm_email_address_visibility: EmailAddressVisibility.Admins, realm_email_auth_enabled: true, realm_email_changes_disabled: true, realm_emails_restricted_to_domains: false, diff --git a/src/api/initialDataTypes.js b/src/api/initialDataTypes.js index 167b13d07d1..64a26109b17 100644 --- a/src/api/initialDataTypes.js +++ b/src/api/initialDataTypes.js @@ -231,7 +231,9 @@ export type InitialDataRealm = $ReadOnly<{| // TODO(server-5.0): Added in feat. 75, replacing realm_allow_community_topic_editing realm_edit_topic_policy?: number, - realm_email_address_visibility: EmailAddressVisibility, + // TODO(server-7.0): Removed in feat. 163 + realm_email_address_visibility?: EmailAddressVisibility, + realm_email_auth_enabled: boolean, realm_email_changes_disabled: boolean, realm_emails_restricted_to_domains: boolean, diff --git a/src/api/realmDataTypes.js b/src/api/realmDataTypes.js index 567d8af1149..41f6182f9d1 100644 --- a/src/api/realmDataTypes.js +++ b/src/api/realmDataTypes.js @@ -59,7 +59,7 @@ export type RealmDataForUpdate = $ReadOnly<{ InitialDataRealm['realm_disallow_disposable_email_addresses'], edit_topic_policy: InitialDataRealm['realm_edit_topic_policy'], - email_address_visibility: + email_address_visibility: // removed in feat. 163 InitialDataRealm['realm_email_address_visibility'], email_changes_disabled: InitialDataRealm['realm_email_changes_disabled'], diff --git a/src/realm/__tests__/realmReducer-test.js b/src/realm/__tests__/realmReducer-test.js index b829d5a81b8..c8fc8be9a50 100644 --- a/src/realm/__tests__/realmReducer-test.js +++ b/src/realm/__tests__/realmReducer-test.js @@ -68,7 +68,7 @@ describe('realmReducer', () => { waitingPeriodThreshold: action.data.realm_waiting_period_threshold, allowEditHistory: action.data.realm_allow_edit_history, enableReadReceipts: action.data.realm_enable_read_receipts, - emailAddressVisibility: action.data.realm_email_address_visibility, + emailAddressVisibility: null, // // InitialDataRealmUser diff --git a/src/realm/realmReducer.js b/src/realm/realmReducer.js index 4d5479810af..08999a49419 100644 --- a/src/realm/realmReducer.js +++ b/src/realm/realmReducer.js @@ -8,7 +8,6 @@ import type { import { CreatePublicOrPrivateStreamPolicy, CreateWebPublicStreamPolicy, - EmailAddressVisibility, } from '../api/permissionsTypes'; import { EventTypes } from '../api/eventTypes'; import { @@ -53,7 +52,7 @@ const initialState = { waitingPeriodThreshold: 90, allowEditHistory: false, enableReadReceipts: false, - emailAddressVisibility: EmailAddressVisibility.Admins, + emailAddressVisibility: null, // // InitialDataRealmUser @@ -165,7 +164,7 @@ export default ( waitingPeriodThreshold: action.data.realm_waiting_period_threshold, allowEditHistory: action.data.realm_allow_edit_history, enableReadReceipts: action.data.realm_enable_read_receipts ?? false, - emailAddressVisibility: action.data.realm_email_address_visibility, + emailAddressVisibility: action.data.realm_email_address_visibility ?? null, // // InitialDataRealmUser diff --git a/src/reduxTypes.js b/src/reduxTypes.js index 9ff22d49064..c6a6eae5049 100644 --- a/src/reduxTypes.js +++ b/src/reduxTypes.js @@ -310,7 +310,7 @@ export type RealmState = {| +waitingPeriodThreshold: number, +allowEditHistory: boolean, +enableReadReceipts: boolean, - +emailAddressVisibility: EmailAddressVisibility, + +emailAddressVisibility: EmailAddressVisibility | null, // // InitialDataRealmUser diff --git a/src/storage/__tests__/migrations-test.js b/src/storage/__tests__/migrations-test.js index dc8dd963eff..d00540e2c47 100644 --- a/src/storage/__tests__/migrations-test.js +++ b/src/storage/__tests__/migrations-test.js @@ -105,7 +105,7 @@ describe('migrations', () => { // What `base` becomes after all migrations. const endBase = { ...base52, - migrations: { version: 60 }, + migrations: { version: 61 }, }; for (const [desc, before, after] of [ @@ -128,9 +128,9 @@ describe('migrations', () => { // redundant with this one, because none of the migration steps notice // whether any properties outside `storeKeys` are present or not. [ - 'check dropCache at 60', + 'check dropCache at 61', // Just before the `dropCache`, plus a `cacheKeys` property, plus junk. - { ...base52, migrations: { version: 59 }, mute: [], nonsense: [1, 2, 3] }, + { ...base52, migrations: { version: 60 }, mute: [], nonsense: [1, 2, 3] }, // Should wind up with the same result as without the extra properties. endBase, ], diff --git a/src/storage/migrations.js b/src/storage/migrations.js index c0af14ff851..e74afc467df 100644 --- a/src/storage/migrations.js +++ b/src/storage/migrations.js @@ -517,6 +517,9 @@ const migrationsInner: {| [string]: (LessPartialState) => LessPartialState |} = // Discard invalid enum values from `state.mute`. '60': dropCache, + // Fix emailAddressVisibility accidentally being undefined/dropped + '61': dropCache, + // TIP: When adding a migration, consider just using `dropCache`. // (See its jsdoc for guidance on when that's the right answer.) }; diff --git a/src/users/userSelectors.js b/src/users/userSelectors.js index 42d2a0028b0..443548387fe 100644 --- a/src/users/userSelectors.js +++ b/src/users/userSelectors.js @@ -323,9 +323,7 @@ export function getDisplayEmailForUser(realm: RealmState, user: UserOrBot): stri if (user.delivery_email !== undefined) { return user.delivery_email; } else if (realm.emailAddressVisibility === EmailAddressVisibility.Everyone) { - // On future servers, we expect this case will never happen: we'll always include - // a delivery_email when you have access, including when the visibility is Everyone - // https://github.com/zulip/zulip-mobile/pull/5515#discussion_r997731727 + // TODO(server-7.0): Not reached on FL 163+, where delivery_email is always present. return user.email; } else { return null;