mirror of https://github.com/zulip/zulip.git
stream_data: Always initialize pin_to_top.
This simplifies the StreamSubscription type, and parallels how we always initialize every other property that isn’t in NeverSubscribedStream (audible_notifications, desktop_notifications, email_notifications, push_notifications, wildcard_mentions_notify, color, is_muted). email_address was already optional. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
44fde64c42
commit
9c2f38193d
|
@ -74,7 +74,7 @@ type StreamContext = {
|
||||||
invite_only: boolean;
|
invite_only: boolean;
|
||||||
is_web_public: boolean;
|
is_web_public: boolean;
|
||||||
stream_name: string;
|
stream_name: string;
|
||||||
pin_to_top: boolean | undefined;
|
pin_to_top: boolean;
|
||||||
is_muted: boolean;
|
is_muted: boolean;
|
||||||
stream_color: string;
|
stream_color: string;
|
||||||
stream_header_color: string;
|
stream_header_color: string;
|
||||||
|
|
|
@ -736,6 +736,7 @@ export function create_sub_from_server_data(
|
||||||
render_subscribers: !realm.realm_is_zephyr_mirror_realm || attrs.invite_only,
|
render_subscribers: !realm.realm_is_zephyr_mirror_realm || attrs.invite_only,
|
||||||
newly_subscribed: false,
|
newly_subscribed: false,
|
||||||
is_muted: false,
|
is_muted: false,
|
||||||
|
pin_to_top: false,
|
||||||
desktop_notifications: null,
|
desktop_notifications: null,
|
||||||
audible_notifications: null,
|
audible_notifications: null,
|
||||||
push_notifications: null,
|
push_notifications: null,
|
||||||
|
|
|
@ -471,7 +471,7 @@ class StreamSidebarRow {
|
||||||
}
|
}
|
||||||
|
|
||||||
update_whether_active(): void {
|
update_whether_active(): void {
|
||||||
if (stream_list_sort.has_recent_activity(this.sub) || this.sub.pin_to_top === true) {
|
if (stream_list_sort.has_recent_activity(this.sub) || this.sub.pin_to_top) {
|
||||||
this.$list_item.removeClass("inactive_stream");
|
this.$list_item.removeClass("inactive_stream");
|
||||||
} else {
|
} else {
|
||||||
this.$list_item.addClass("inactive_stream");
|
this.$list_item.addClass("inactive_stream");
|
||||||
|
|
|
@ -9,8 +9,6 @@ import type {
|
||||||
stream_subscription_schema,
|
stream_subscription_schema,
|
||||||
} from "./stream_types";
|
} from "./stream_types";
|
||||||
|
|
||||||
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<T>;
|
|
||||||
|
|
||||||
export type Stream = z.infer<typeof stream_schema>;
|
export type Stream = z.infer<typeof stream_schema>;
|
||||||
export type StreamSpecificNotificationSettings = z.infer<
|
export type StreamSpecificNotificationSettings = z.infer<
|
||||||
typeof stream_specific_notification_settings_schema
|
typeof stream_specific_notification_settings_schema
|
||||||
|
@ -28,11 +26,7 @@ export type ExtraStreamAttrs = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// This is the actual type of subscription objects we use in the app.
|
// This is the actual type of subscription objects we use in the app.
|
||||||
export type StreamSubscription = PartialBy<
|
export type StreamSubscription = Omit<ApiStreamSubscription, "subscribers"> & ExtraStreamAttrs;
|
||||||
Omit<ApiStreamSubscription, "subscribers">,
|
|
||||||
"pin_to_top" | "email_address"
|
|
||||||
> &
|
|
||||||
ExtraStreamAttrs;
|
|
||||||
|
|
||||||
const subs_by_stream_id = new Map<number, StreamSubscription>();
|
const subs_by_stream_id = new Map<number, StreamSubscription>();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue