local_message: Convert module to typescript.

This commit is contained in:
evykassirer 2023-12-24 19:07:52 -08:00 committed by Anders Kaseorg
parent b20694aa07
commit 5f5e77afd5
3 changed files with 5 additions and 7 deletions

View File

@ -123,7 +123,7 @@ EXEMPT_FILES = make_set(
"web/src/list_util.ts",
"web/src/list_widget.ts",
"web/src/loading.ts",
"web/src/local_message.js",
"web/src/local_message.ts",
"web/src/localstorage.ts",
"web/src/message_actions_popover.js",
"web/src/message_edit.js",

View File

@ -2,19 +2,16 @@ import {all_messages_data} from "./all_messages_data";
import * as blueslip from "./blueslip";
import {page_params} from "./page_params";
function truncate_precision(float) {
function truncate_precision(float: number): number {
return Number.parseFloat(float.toFixed(3));
}
export const get_next_id_float = (function () {
const already_used = new Set();
return function () {
return function (): number | undefined {
const local_id_increment = 0.01;
let latest = page_params.max_message_id;
if (all_messages_data.last() !== undefined) {
latest = all_messages_data.last().id;
}
let latest = all_messages_data.last()?.id ?? page_params.max_message_id;
latest = Math.max(0, latest);
const local_id_float = truncate_precision(latest + local_id_increment);

View File

@ -41,6 +41,7 @@ export const page_params: {
max_avatar_file_size_mib: number;
max_icon_file_size_mib: number;
max_logo_file_size_mib: number;
max_message_id: number;
muted_users: {id: number; timestamp: number}[];
narrow_stream?: string;
narrow: Term[];