diff --git a/tools/test-js-with-node b/tools/test-js-with-node index df7d71538e..68ef214e8c 100755 --- a/tools/test-js-with-node +++ b/tools/test-js-with-node @@ -142,7 +142,7 @@ EXEMPT_FILES = make_set( "web/src/read_receipts.js", "web/src/ready.ts", "web/src/realm_icon.ts", - "web/src/realm_logo.js", + "web/src/realm_logo.ts", "web/src/realm_playground.ts", "web/src/realm_user_settings_defaults.ts", "web/src/recent_view_ui.js", diff --git a/web/src/page_params.ts b/web/src/page_params.ts index 0d359a0ec1..b116bb992d 100644 --- a/web/src/page_params.ts +++ b/web/src/page_params.ts @@ -22,6 +22,7 @@ export const page_params: { is_spectator: boolean; max_avatar_file_size_mib: number; max_icon_file_size_mib: number; + max_logo_file_size_mib: number; muted_users: {id: number; timestamp: number}[]; needs_tutorial: boolean; page_load_time: number; @@ -41,6 +42,10 @@ export const page_params: { realm_invite_to_realm_policy: number; realm_invite_to_stream_policy: number; realm_is_zephyr_mirror_realm: boolean; + realm_logo_source: string; + realm_logo_url: string; + realm_night_logo_source: string; + realm_night_logo_url: string; realm_move_messages_between_streams_policy: number; realm_name_changes_disabled: boolean; realm_name: string; diff --git a/web/src/realm_logo.js b/web/src/realm_logo.ts similarity index 80% rename from web/src/realm_logo.js rename to web/src/realm_logo.ts index b4ed1702f9..7515e37b2d 100644 --- a/web/src/realm_logo.js +++ b/web/src/realm_logo.ts @@ -5,8 +5,9 @@ import {page_params} from "./page_params"; import * as settings_data from "./settings_data"; import * as ui_util from "./ui_util"; import * as upload_widget from "./upload_widget"; +import type {UploadFunction} from "./upload_widget"; -export function build_realm_logo_widget(upload_function, is_night) { +export function build_realm_logo_widget(upload_function: UploadFunction, is_night: boolean): void { let logo_section_id = "#realm-day-logo-upload-widget"; let logo_source = page_params.realm_logo_source; @@ -16,11 +17,11 @@ export function build_realm_logo_widget(upload_function, is_night) { } const $delete_button_elem = $(logo_section_id + " .image-delete-button"); - const $file_input_elem = $(logo_section_id + " .image_file_input"); + const $file_input_elem = $(logo_section_id + " .image_file_input"); const $file_input_error_elem = $(logo_section_id + " .image_file_input_error"); const $upload_button_elem = $(logo_section_id + " .image_upload_button"); - const get_file_input = function () { + const get_file_input = function (): JQuery { return $file_input_elem.expectOne(); }; @@ -38,7 +39,7 @@ export function build_realm_logo_widget(upload_function, is_night) { $delete_button_elem.on("click", (e) => { e.preventDefault(); e.stopPropagation(); - channel.del({ + void channel.del({ url: "/json/realm/logo", data, }); @@ -53,7 +54,11 @@ export function build_realm_logo_widget(upload_function, is_night) { ); } -function change_logo_delete_button(logo_source, $logo_delete_button, $file_input) { +function change_logo_delete_button( + logo_source: string, + $logo_delete_button: JQuery, + $file_input: JQuery, +): void { if (logo_source === "U") { $logo_delete_button.show(); } else { @@ -64,9 +69,11 @@ function change_logo_delete_button(logo_source, $logo_delete_button, $file_input } } -export function render() { - const $file_input = $("#realm-day-logo-upload-widget .image_file_input"); - const $night_file_input = $("#realm-night-logo-upload-widget .realm-logo-file-input"); +export function render(): void { + const $file_input = $("#realm-day-logo-upload-widget .image_file_input"); + const $night_file_input = $( + "#realm-night-logo-upload-widget .realm-logo-file-input", + ); $("#realm-day-logo-upload-widget .image-block").attr("src", page_params.realm_logo_url); if (page_params.realm_night_logo_source === "D" && page_params.realm_logo_source !== "D") { @@ -101,7 +108,7 @@ export function render() { ); } -export function initialize() { +export function initialize(): void { // render once render();