From 009b5650db8c4b0295210adecfd92b4ad0dad1a2 Mon Sep 17 00:00:00 2001 From: Rohit Bansal <40559587+Rohit3523@users.noreply.github.com> Date: Tue, 14 Oct 2025 02:54:28 +0530 Subject: [PATCH 01/10] added dayjs --- app/containers/MessageActions/index.tsx | 10 ++--- .../components/Quotes/Quote.tsx | 4 +- app/containers/MessageSeparator.tsx | 4 +- app/containers/Passcode/utils.ts | 4 +- .../useSupportedVersionMessage.ts | 5 +-- app/containers/UIKit/DatePicker.tsx | 4 +- .../message/Components/Attachments/Reply.tsx | 4 +- app/containers/message/Time.tsx | 4 +- app/i18n/dayjs.ts | 21 ++++++++++ app/i18n/index.ts | 7 ++-- app/i18n/moment.ts | 21 ---------- app/lib/dayjs/index.ts | 38 +++++++++++++++++++ app/lib/methods/AudioManager.ts | 4 +- app/lib/methods/checkSupportedVersions.ts | 6 +-- app/lib/methods/getServerInfo.ts | 4 +- .../methods/helpers/localAuthentication.ts | 4 +- app/lib/methods/helpers/normalizeMessage.ts | 5 +-- app/lib/methods/helpers/room.ts | 9 ++--- app/lib/methods/loadMessagesForRoom.ts | 5 +-- app/lib/methods/loadNextMessages.ts | 4 +- app/lib/methods/loadSurroundingMessages.ts | 6 +-- app/sagas/login.js | 4 +- app/views/DiscussionsView/Item.tsx | 4 +- app/views/InviteUsersView/index.tsx | 6 +-- app/views/ReadReceiptView/index.tsx | 4 +- app/views/RoomInfoView/Timezone.tsx | 4 +- app/views/RoomView/index.tsx | 8 ++-- package.json | 1 + yarn.lock | 5 +++ 29 files changed, 124 insertions(+), 85 deletions(-) create mode 100644 app/i18n/dayjs.ts delete mode 100644 app/i18n/moment.ts create mode 100644 app/lib/dayjs/index.ts diff --git a/app/containers/MessageActions/index.tsx b/app/containers/MessageActions/index.tsx index 5a667c97702..4302a8bb1b6 100644 --- a/app/containers/MessageActions/index.tsx +++ b/app/containers/MessageActions/index.tsx @@ -2,8 +2,8 @@ import React, { forwardRef, useImperativeHandle } from 'react'; import { Alert, Share } from 'react-native'; import Clipboard from '@react-native-clipboard/clipboard'; import { connect } from 'react-redux'; -import moment from 'moment'; +import dayjs from '../../lib/dayjs'; import database from '../../lib/database'; import { getSubscriptionByRoomId } from '../../lib/database/services/Subscription'; import I18n from '../../i18n'; @@ -148,11 +148,11 @@ const MessageActions = React.memo( if (blockEditInMinutes) { let msgTs; if (message.ts != null) { - msgTs = moment(message.ts); + msgTs = dayjs(message.ts); } let currentTsDiff = 0; if (msgTs != null) { - currentTsDiff = moment().diff(msgTs, 'minutes'); + currentTsDiff = dayjs().diff(msgTs, 'minutes'); } return currentTsDiff < blockEditInMinutes; } @@ -179,11 +179,11 @@ const MessageActions = React.memo( if (blockDeleteInMinutes != null && blockDeleteInMinutes !== 0) { let msgTs; if (message.ts != null) { - msgTs = moment(message.ts); + msgTs = dayjs(message.ts); } let currentTsDiff = 0; if (msgTs != null) { - currentTsDiff = moment().diff(msgTs, 'minutes'); + currentTsDiff = dayjs().diff(msgTs, 'minutes'); } return currentTsDiff < blockDeleteInMinutes; } diff --git a/app/containers/MessageComposer/components/Quotes/Quote.tsx b/app/containers/MessageComposer/components/Quotes/Quote.tsx index 80782dee217..c5436f19938 100644 --- a/app/containers/MessageComposer/components/Quotes/Quote.tsx +++ b/app/containers/MessageComposer/components/Quotes/Quote.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { View, Text } from 'react-native'; -import moment from 'moment'; +import dayjs from '../../../../lib/dayjs'; import { useTheme } from '../../../../theme'; import sharedStyles from '../../../../views/Styles'; import { useRoomContext } from '../../../../views/RoomView/context'; @@ -25,7 +25,7 @@ export const Quote = ({ messageId }: { messageId: string }) => { if (message) { username = useRealName ? message.u?.name || message.u?.username || '' : message.u?.username || ''; msg = message.msg || ''; - time = message.ts ? moment(message.ts).format('LT') : ''; + time = message.ts ? dayjs(message.ts).format('LT') : ''; } if (!message) { diff --git a/app/containers/MessageSeparator.tsx b/app/containers/MessageSeparator.tsx index ecc768f0357..6ba013755ae 100644 --- a/app/containers/MessageSeparator.tsx +++ b/app/containers/MessageSeparator.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; -import moment from 'moment'; +import dayjs from '../lib/dayjs'; import I18n from '../i18n'; import sharedStyles from '../views/Styles'; import { themes } from '../lib/constants/colors'; @@ -36,7 +36,7 @@ const MessageSeparator = ({ ts, unread }: { ts?: Date | string | null; unread?: return null; } - const date = ts ? moment(ts).format('LL') : null; + const date = ts ? dayjs(ts).format('LL') : null; const unreadLine = { backgroundColor: themes[theme].buttonBackgroundDangerDefault }; const unreadText = { color: themes[theme].fontDanger }; if (ts && unread) { diff --git a/app/containers/Passcode/utils.ts b/app/containers/Passcode/utils.ts index bec7bcf7519..c0bb39f3ef4 100644 --- a/app/containers/Passcode/utils.ts +++ b/app/containers/Passcode/utils.ts @@ -1,12 +1,12 @@ import AsyncStorage from '@react-native-async-storage/async-storage'; -import moment from 'moment'; +import dayjs from '../../lib/dayjs'; import { LOCKED_OUT_TIMER_KEY, TIME_TO_LOCK } from '../../lib/constants/localAuthentication'; export const getLockedUntil = async () => { const t = await AsyncStorage.getItem(LOCKED_OUT_TIMER_KEY); if (t) { - return moment(t).add(TIME_TO_LOCK).toDate(); + return dayjs(t).add(TIME_TO_LOCK).toDate(); } return null; }; diff --git a/app/containers/SupportedVersions/useSupportedVersionMessage.ts b/app/containers/SupportedVersions/useSupportedVersionMessage.ts index d4b31d10854..85f9965b2d7 100644 --- a/app/containers/SupportedVersions/useSupportedVersionMessage.ts +++ b/app/containers/SupportedVersions/useSupportedVersionMessage.ts @@ -1,5 +1,4 @@ -import moment from 'moment'; - +import dayjs from '../../lib/dayjs'; import { useAppSelector } from '../../lib/hooks/useAppSelector'; const applyParams = (message: string, params: Record) => { @@ -25,7 +24,7 @@ export const useSupportedVersionMessage = () => { instance_email: email, instance_ws_name: name, instance_domain: server, - remaining_days: moment(expiration).diff(new Date(), 'days'), + remaining_days: dayjs(expiration).diff(new Date(), 'days'), instance_version: version, ...message?.params }; diff --git a/app/containers/UIKit/DatePicker.tsx b/app/containers/UIKit/DatePicker.tsx index 0e75b21d204..53b291924c9 100644 --- a/app/containers/UIKit/DatePicker.tsx +++ b/app/containers/UIKit/DatePicker.tsx @@ -3,8 +3,8 @@ import { StyleSheet, Text, unstable_batchedUpdates, View } from 'react-native'; import DateTimePicker, { BaseProps } from '@react-native-community/datetimepicker'; import Touchable from 'react-native-platform-touchable'; import { BlockContext } from '@rocket.chat/ui-kit'; -import moment from 'moment'; +import dayjs from '../../lib/dayjs'; import Button from '../Button'; import { textParser } from './utils'; import { themes } from '../../lib/constants/colors'; @@ -54,7 +54,7 @@ export const DatePicker = ({ element, language, action, context, loading, value, onShow(false); } }); - action({ value: moment(newDate).format('YYYY-MM-DD') }); + action({ value: dayjs(newDate).format('YYYY-MM-DD') }); } }; diff --git a/app/containers/message/Components/Attachments/Reply.tsx b/app/containers/message/Components/Attachments/Reply.tsx index e580b3f4245..24d6bd5050f 100644 --- a/app/containers/message/Components/Attachments/Reply.tsx +++ b/app/containers/message/Components/Attachments/Reply.tsx @@ -1,5 +1,4 @@ import { dequal } from 'dequal'; -import moment from 'moment'; import React, { useContext, useState } from 'react'; import { StyleSheet, Text, View } from 'react-native'; import { Image } from 'expo-image'; @@ -17,6 +16,7 @@ import { Attachments } from './components'; import MessageContext from '../../Context'; import Touchable from '../../Touchable'; import messageStyles from '../../styles'; +import dayjs from '../../../../lib/dayjs'; const styles = StyleSheet.create({ button: { @@ -103,7 +103,7 @@ const Title = React.memo( ({ attachment, timeFormat, theme }: { attachment: IAttachment; timeFormat?: string; theme: TSupportedThemes }) => { 'use memo'; - const time = attachment.message_link && attachment.ts ? moment(attachment.ts).format(timeFormat) : null; + const time = attachment.message_link && attachment.ts ? dayjs(attachment.ts).format(timeFormat) : null; return ( {attachment.author_name ? ( diff --git a/app/containers/message/Time.tsx b/app/containers/message/Time.tsx index efeb4ac5063..78ae7ab80f5 100644 --- a/app/containers/message/Time.tsx +++ b/app/containers/message/Time.tsx @@ -1,7 +1,7 @@ -import moment from 'moment'; import React from 'react'; import { Text } from 'react-native'; +import dayjs from '../../lib/dayjs'; import { useTheme } from '../../theme'; import messageStyles from './styles'; @@ -15,7 +15,7 @@ const MessageTime = ({ timeFormat, ts }: IMessageTime) => { const { colors } = useTheme(); - const time = moment(ts).format(timeFormat); + const time = dayjs(ts).format(timeFormat); return {time}; }; diff --git a/app/i18n/dayjs.ts b/app/i18n/dayjs.ts new file mode 100644 index 00000000000..69c33417758 --- /dev/null +++ b/app/i18n/dayjs.ts @@ -0,0 +1,21 @@ +const localeKeys: { [key: string]: string } = { + en: 'en', + ar: 'ar', + de: 'de', + 'es-ES': 'es', + fi: 'fi', + fr: 'fr', + it: 'it', + ja: 'ja', + nl: 'nl', + 'pt-BR': 'pt-br', + 'pt-PT': 'pt', + ru: 'ru', + 'sl-SI': 'sl', + sv: 'sv', + tr: 'tr', + 'zh-CN': 'zh-cn', + 'zh-TW': 'zh-tw' +}; + +export const toDayJsLocale = (locale: string): string => localeKeys[locale] || locale; diff --git a/app/i18n/index.ts b/app/i18n/index.ts index 0124dffa5ce..91189b48d42 100644 --- a/app/i18n/index.ts +++ b/app/i18n/index.ts @@ -1,10 +1,9 @@ import i18n from 'i18n-js'; import { I18nManager } from 'react-native'; import * as RNLocalize from 'react-native-localize'; -import moment from 'moment'; -import 'moment/min/locales'; -import { toMomentLocale } from './moment'; +import dayjs from '../lib/dayjs/index'; +import { toDayJsLocale } from './dayjs'; import { isRTL } from './isRTL'; import englishJson from './locales/en.json'; @@ -177,7 +176,7 @@ export const setLanguage = (l: string) => { // TODO: Review this logic // @ts-ignore i18n.isRTL = I18nManager.isRTL; - moment.locale(toMomentLocale(locale)); + dayjs.locale(toDayJsLocale(locale)); }; i18n.translations = { en: translations.en?.() }; diff --git a/app/i18n/moment.ts b/app/i18n/moment.ts deleted file mode 100644 index 88254b755df..00000000000 --- a/app/i18n/moment.ts +++ /dev/null @@ -1,21 +0,0 @@ -const localeKeys: { [key: string]: string } = { - en: 'en', - ar: 'ar', - de: 'de', - 'es-ES': 'es', - fi: 'fi', - fr: 'fr', - it: 'it', - ja: 'ja', - nl: 'nl', - 'pt-BR': 'pt-br', - 'pt-PT': 'pt', - ru: 'ru', - 'sl-SI': 'sl', - sv: 'sv', - tr: 'tr', - 'zh-CN': 'zh-cn', - 'zh-TW': 'zh-tw' -}; - -export const toMomentLocale = (locale: string): string => localeKeys[locale]; diff --git a/app/lib/dayjs/index.ts b/app/lib/dayjs/index.ts new file mode 100644 index 00000000000..9d881d2d888 --- /dev/null +++ b/app/lib/dayjs/index.ts @@ -0,0 +1,38 @@ +import dayjs from 'dayjs'; +import utc from 'dayjs/plugin/utc'; +import timezone from 'dayjs/plugin/timezone'; +import calendar from 'dayjs/plugin/calendar'; +import relativeTime from 'dayjs/plugin/relativeTime'; + +import 'dayjs/locale/en'; +import 'dayjs/locale/ar'; +import 'dayjs/locale/bn'; +import 'dayjs/locale/cs'; +import 'dayjs/locale/de'; +import 'dayjs/locale/es'; +import 'dayjs/locale/fi'; +import 'dayjs/locale/fr'; +import 'dayjs/locale/hi'; +import 'dayjs/locale/hu'; +import 'dayjs/locale/it'; +import 'dayjs/locale/ja'; +import 'dayjs/locale/nl'; +import 'dayjs/locale/nb'; +import 'dayjs/locale/nn'; +import 'dayjs/locale/pt-br'; +import 'dayjs/locale/pt'; +import 'dayjs/locale/ru'; +import 'dayjs/locale/sl'; +import 'dayjs/locale/sv'; +import 'dayjs/locale/ta'; +import 'dayjs/locale/te'; +import 'dayjs/locale/tr'; +import 'dayjs/locale/zh-cn'; +import 'dayjs/locale/zh-tw'; + +dayjs.extend(utc); +dayjs.extend(timezone); +dayjs.extend(calendar); +dayjs.extend(relativeTime); + +export default dayjs; \ No newline at end of file diff --git a/app/lib/methods/AudioManager.ts b/app/lib/methods/AudioManager.ts index c6195baa6dc..d0917f0030e 100644 --- a/app/lib/methods/AudioManager.ts +++ b/app/lib/methods/AudioManager.ts @@ -1,7 +1,7 @@ import { AVPlaybackStatus, Audio } from 'expo-av'; import { Q } from '@nozbe/watermelondb'; -import moment from 'moment'; +import dayjs from '../../lib/dayjs'; import { getMessageById } from '../database/services/Message'; import database from '../database'; import { getFilePathAudio } from './getFilePathAudio'; @@ -120,7 +120,7 @@ class AudioManagerClass { const msg = await getMessageById(msgId); if (msg) { const db = database.active; - const whereClause: Q.Clause[] = [Q.sortBy('ts', Q.asc), Q.where('ts', Q.gt(moment(msg.ts).valueOf())), Q.take(1)]; + const whereClause: Q.Clause[] = [Q.sortBy('ts', Q.asc), Q.where('ts', Q.gt(dayjs(msg.ts).valueOf())), Q.take(1)]; if (msg.tmid) { whereClause.push(Q.where('tmid', msg.tmid || msg.id)); diff --git a/app/lib/methods/checkSupportedVersions.ts b/app/lib/methods/checkSupportedVersions.ts index 2fc7acb16bc..a5e0b733cf6 100644 --- a/app/lib/methods/checkSupportedVersions.ts +++ b/app/lib/methods/checkSupportedVersions.ts @@ -1,7 +1,7 @@ -import moment from 'moment'; import coerce from 'semver/functions/coerce'; import satisfies from 'semver/functions/satisfies'; +import dayjs from '../../lib/dayjs'; import { ISupportedVersionsData, TSVDictionary, TSVMessage, TSVStatus } from '../../definitions'; import builtInSupportedVersions from '../../../app-supportedversions.json'; @@ -12,11 +12,11 @@ export const getMessage = ({ messages?: TSVMessage[]; expiration?: string; }): TSVMessage | undefined => { - if (!messages?.length || !expiration || moment(expiration).diff(new Date(), 'days') < 0) { + if (!messages?.length || !expiration || dayjs(expiration).diff(new Date(), 'days') < 0) { return; } const sortedMessages = messages.sort((a, b) => a.remainingDays - b.remainingDays); - return sortedMessages.find(({ remainingDays }) => moment(expiration).diff(new Date(), 'hours') <= remainingDays * 24); + return sortedMessages.find(({ remainingDays }) => dayjs(expiration).diff(new Date(), 'hours') <= remainingDays * 24); }; const getStatus = ({ expiration, message }: { expiration?: string; message?: TSVMessage }): TSVStatus => { diff --git a/app/lib/methods/getServerInfo.ts b/app/lib/methods/getServerInfo.ts index 52e252ddac2..f52d89ce147 100644 --- a/app/lib/methods/getServerInfo.ts +++ b/app/lib/methods/getServerInfo.ts @@ -1,6 +1,6 @@ import { KJUR } from 'jsrsasign'; -import moment from 'moment'; +import dayjs from '../../lib/dayjs'; import { getSupportedVersionsCloud } from '../services/restApi'; import { TCloudInfo, IServerInfo, ISupportedVersions, ISupportedVersionsData, IApiServerInfo } from '../../definitions'; import { selectServerFailure } from '../../actions/server'; @@ -75,7 +75,7 @@ export async function getServerInfo(server: string): Promise const serverRecord = await getServerById(server); if ( serverRecord?.supportedVersionsUpdatedAt && - moment(new Date()).diff(serverRecord?.supportedVersionsUpdatedAt, 'hours') <= SV_CLOUD_UPDATE_INTERVAL + dayjs(new Date()).diff(serverRecord?.supportedVersionsUpdatedAt, 'hours') <= SV_CLOUD_UPDATE_INTERVAL ) { return { ...serverInfo, diff --git a/app/lib/methods/helpers/localAuthentication.ts b/app/lib/methods/helpers/localAuthentication.ts index 92e60f93f06..1921dda39f1 100644 --- a/app/lib/methods/helpers/localAuthentication.ts +++ b/app/lib/methods/helpers/localAuthentication.ts @@ -2,8 +2,8 @@ import * as LocalAuthentication from 'expo-local-authentication'; import RNBootSplash from 'react-native-bootsplash'; import AsyncStorage from '@react-native-async-storage/async-storage'; import { sha256 } from 'js-sha256'; -import moment from 'moment'; +import dayjs from '../../../lib/dayjs'; import UserPreferences from '../userPreferences'; import { store } from '../../store/auxStore'; import database from '../../database'; @@ -146,7 +146,7 @@ export const localAuthenticate = async (server: string): Promise => { // `checkHasPasscode` results newPasscode = true if a passcode has been set if (!result?.newPasscode) { // diff to last authenticated session - const diffToLastSession = moment(timesync).diff(serverRecord?.lastLocalAuthenticatedSession, 'seconds'); + const diffToLastSession = dayjs(timesync).diff(serverRecord?.lastLocalAuthenticatedSession, 'seconds'); // if it was not possible to get `timesync` from server or the last authenticated session is older than the configured auto lock time, authentication is required if (!timesync || (serverRecord?.autoLockTime && diffToLastSession >= serverRecord.autoLockTime)) { diff --git a/app/lib/methods/helpers/normalizeMessage.ts b/app/lib/methods/helpers/normalizeMessage.ts index 186a7e188dd..8237ee9b92e 100644 --- a/app/lib/methods/helpers/normalizeMessage.ts +++ b/app/lib/methods/helpers/normalizeMessage.ts @@ -1,5 +1,4 @@ -import moment from 'moment'; - +import dayjs from '../../../lib/dayjs'; import parseUrls from './parseUrls'; import type { IAttachment, IMessage, IThreadResult } from '../../../definitions'; @@ -15,7 +14,7 @@ function normalizeAttachments(msg: TMsg) { .map(att => { att.fields = att.fields || []; if (att.ts) { - att.ts = moment(att.ts).toDate(); + att.ts = dayjs(att.ts).toDate(); } att = normalizeAttachments(att as TMsg); return att; diff --git a/app/lib/methods/helpers/room.ts b/app/lib/methods/helpers/room.ts index def94d60edd..0713868f100 100644 --- a/app/lib/methods/helpers/room.ts +++ b/app/lib/methods/helpers/room.ts @@ -1,5 +1,4 @@ -import moment from 'moment'; - +import dayjs from '../../../lib/dayjs'; import { themes } from '../../constants/colors'; import I18n from '../../../i18n'; import { IAttachment, SubscriptionType, TSubscriptionModel } from '../../../definitions'; @@ -23,7 +22,7 @@ export const capitalize = (s: string): string => { }; export const formatDateAccessibility = (date: string | Date): string => - moment(date).calendar(null, { + dayjs(date).calendar(null, { lastDay: `[${I18n.t('Last_updated')}] [${I18n.t('Yesterday')}]`, sameDay: `[${I18n.t('Last_updated_at')}] LT`, lastWeek: `[${I18n.t('Last_updated_on')}] dddd`, @@ -31,7 +30,7 @@ export const formatDateAccessibility = (date: string | Date): string => }); export const formatDate = (date: string | Date): string => - moment(date).calendar(null, { + dayjs(date).calendar(null, { lastDay: `[${I18n.t('Yesterday')}]`, sameDay: 'LT', lastWeek: 'dddd', @@ -39,7 +38,7 @@ export const formatDate = (date: string | Date): string => }); export const formatDateThreads = (date: string | Date): string => - moment(date).calendar(null, { + dayjs(date).calendar(null, { sameDay: 'LT', lastDay: `[${I18n.t('Yesterday')}] LT`, lastWeek: 'dddd LT', diff --git a/app/lib/methods/loadMessagesForRoom.ts b/app/lib/methods/loadMessagesForRoom.ts index 2f0d03de64d..78bdba44547 100644 --- a/app/lib/methods/loadMessagesForRoom.ts +++ b/app/lib/methods/loadMessagesForRoom.ts @@ -1,5 +1,4 @@ -import moment from 'moment'; - +import dayjs from '../../lib/dayjs'; import { MessageTypeLoad } from '../constants/messageTypeLoad'; import { IMessage, TMessageModel } from '../../definitions'; import log from './helpers/log'; @@ -46,7 +45,7 @@ export function loadMessagesForRoom(args: { const loadMoreMessage = { _id: generateLoadMoreId(lastMessage._id as string), rid: lastMessage.rid, - ts: moment(lastMessage.ts).subtract(1, 'millisecond').toString(), + ts: dayjs(lastMessage.ts).subtract(1, 'millisecond').toString(), t: MessageTypeLoad.MORE, msg: lastMessage.msg } as IMessage; diff --git a/app/lib/methods/loadNextMessages.ts b/app/lib/methods/loadNextMessages.ts index a63741ac7cb..a182cf4f7c1 100644 --- a/app/lib/methods/loadNextMessages.ts +++ b/app/lib/methods/loadNextMessages.ts @@ -1,7 +1,7 @@ import EJSON from 'ejson'; -import moment from 'moment'; import orderBy from 'lodash/orderBy'; +import dayjs from '../../lib/dayjs'; import log from './helpers/log'; import { getMessageById } from '../database/services/Message'; import { MessageTypeLoad } from '../constants/messageTypeLoad'; @@ -31,7 +31,7 @@ export function loadNextMessages(args: ILoadNextMessages): Promise { const loadMoreItem = { _id: generateLoadMoreId(lastMessage._id), rid: lastMessage.rid, - ts: moment(lastMessage.ts).add(1, 'millisecond'), + ts: dayjs(lastMessage.ts).add(1, 'millisecond'), t: MessageTypeLoad.NEXT_CHUNK }; messages.push(loadMoreItem); diff --git a/app/lib/methods/loadSurroundingMessages.ts b/app/lib/methods/loadSurroundingMessages.ts index 9b9572c888b..589af6cc0a0 100644 --- a/app/lib/methods/loadSurroundingMessages.ts +++ b/app/lib/methods/loadSurroundingMessages.ts @@ -1,7 +1,7 @@ import EJSON from 'ejson'; -import moment from 'moment'; import orderBy from 'lodash/orderBy'; +import dayjs from '../../lib/dayjs'; import log from './helpers/log'; import { getMessageById } from '../database/services/Message'; import { MessageTypeLoad } from '../constants/messageTypeLoad'; @@ -27,7 +27,7 @@ export function loadSurroundingMessages({ messageId, rid }: { messageId: string; const loadMoreItem = { _id: generateLoadMoreId(firstMessage._id), rid: firstMessage.rid, - ts: moment(firstMessage.ts).subtract(1, 'millisecond').toDate(), + ts: dayjs(firstMessage.ts).subtract(1, 'millisecond').toDate(), t: MessageTypeLoad.PREVIOUS_CHUNK, msg: firstMessage.msg } as IMessage; @@ -42,7 +42,7 @@ export function loadSurroundingMessages({ messageId, rid }: { messageId: string; const loadMoreItem = { _id: generateLoadMoreId(lastMessage._id), rid: lastMessage.rid, - ts: moment(lastMessage.ts).add(1, 'millisecond').toDate(), + ts: dayjs(lastMessage.ts).add(1, 'millisecond').toDate(), t: MessageTypeLoad.NEXT_CHUNK, msg: lastMessage.msg } as IMessage; diff --git a/app/sagas/login.js b/app/sagas/login.js index 91dfe225f0c..e9b31b463a2 100644 --- a/app/sagas/login.js +++ b/app/sagas/login.js @@ -4,7 +4,7 @@ import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord'; import { Q } from '@nozbe/watermelondb'; import * as Keychain from 'react-native-keychain'; -import moment from 'moment'; +import dayjs from '../lib/dayjs'; import * as types from '../actions/actionsTypes'; import { appStart } from '../actions/app'; import { selectServerRequest, serverFinishAdd } from '../actions/server'; @@ -55,7 +55,7 @@ const showSupportedVersionsWarning = function* showSupportedVersionsWarning(serv } const serverRecord = yield getServerById(server); const isMasterDetail = yield select(state => state.app.isMasterDetail); - if (!serverRecord || moment(new Date()).diff(serverRecord?.supportedVersionsWarningAt, 'hours') <= 12) { + if (!serverRecord || dayjs(new Date()).diff(serverRecord?.supportedVersionsWarningAt, 'hours') <= 12) { return; } diff --git a/app/views/DiscussionsView/Item.tsx b/app/views/DiscussionsView/Item.tsx index ab978daadaf..8f2a477c5b5 100644 --- a/app/views/DiscussionsView/Item.tsx +++ b/app/views/DiscussionsView/Item.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; import Touchable from 'react-native-platform-touchable'; -import moment from 'moment'; +import dayjs from '../../lib/dayjs'; import { useTheme } from '../../theme'; import Avatar from '../../containers/Avatar'; import sharedStyles from '../Styles'; @@ -58,7 +58,7 @@ const Item = ({ item, onPress }: IItem): React.ReactElement => { let messageDate = ''; if (item?.ts) { - messageTime = moment(item.ts).format('LT'); + messageTime = dayjs(item.ts).format('LT'); messageDate = formatDateThreads(item.ts); } diff --git a/app/views/InviteUsersView/index.tsx b/app/views/InviteUsersView/index.tsx index 9c5d97a9e8c..f891f99e591 100644 --- a/app/views/InviteUsersView/index.tsx +++ b/app/views/InviteUsersView/index.tsx @@ -1,8 +1,8 @@ import React, { useEffect } from 'react'; -import moment from 'moment'; import { ScrollView, Share, View } from 'react-native'; import { useDispatch, useSelector } from 'react-redux'; +import dayjs from '../../lib/dayjs'; import { inviteLinksClear, inviteLinksCreate } from '../../actions/inviteLinks'; import Button from '../../containers/Button'; import Markdown from '../../containers/markdown'; @@ -62,12 +62,12 @@ const InviteUsersView = ({ route, navigation }: IInviteUsersViewProps): React.Re if (invite.maxUses) { const usesLeft = invite.maxUses - invite.uses; return I18n.t('Your_invite_link_will_expire_on__date__or_after__usesLeft__uses', { - date: moment(expiration).format(timeDateFormat), + date: dayjs(expiration).format(timeDateFormat), usesLeft }); } - return I18n.t('Your_invite_link_will_expire_on__date__', { date: moment(expiration).format(timeDateFormat) }); + return I18n.t('Your_invite_link_will_expire_on__date__', { date: dayjs(expiration).format(timeDateFormat) }); } if (invite.maxUses) { diff --git a/app/views/ReadReceiptView/index.tsx b/app/views/ReadReceiptView/index.tsx index 038c5db627a..99f79ff6995 100644 --- a/app/views/ReadReceiptView/index.tsx +++ b/app/views/ReadReceiptView/index.tsx @@ -1,11 +1,11 @@ import React from 'react'; import { FlatList, Text, View, RefreshControl } from 'react-native'; import { dequal } from 'dequal'; -import moment from 'moment'; import { connect } from 'react-redux'; import { NativeStackNavigationOptions, NativeStackNavigationProp } from '@react-navigation/native-stack'; import { RouteProp } from '@react-navigation/core'; +import dayjs from '../../lib/dayjs'; import * as List from '../../containers/List'; import Avatar from '../../containers/Avatar'; import * as HeaderButton from '../../containers/Header/components/HeaderButton'; @@ -112,7 +112,7 @@ class ReadReceiptView extends React.Component { const { theme, Message_TimeAndDateFormat } = this.props; - const time = moment(item.ts).format(Message_TimeAndDateFormat); + const time = dayjs(item.ts).format(Message_TimeAndDateFormat); if (!item?.user?.username) { return null; } diff --git a/app/views/RoomInfoView/Timezone.tsx b/app/views/RoomInfoView/Timezone.tsx index 73a9af64ad1..ea2d34996a0 100644 --- a/app/views/RoomInfoView/Timezone.tsx +++ b/app/views/RoomInfoView/Timezone.tsx @@ -1,6 +1,6 @@ -import moment from 'moment'; import React from 'react'; +import dayjs from '../../lib/dayjs'; import I18n from '../../i18n'; import { useAppSelector } from '../../lib/hooks/useAppSelector'; import Item from './Item'; @@ -11,7 +11,7 @@ const Timezone = ({ utcOffset }: { utcOffset?: number }): React.ReactElement | n if (!utcOffset) return null; return ( - + ); }; diff --git a/app/views/RoomView/index.tsx b/app/views/RoomView/index.tsx index 7f1143411fd..593a74b545a 100644 --- a/app/views/RoomView/index.tsx +++ b/app/views/RoomView/index.tsx @@ -2,13 +2,13 @@ import React from 'react'; import { AccessibilityInfo, InteractionManager, PixelRatio, Text, View } from 'react-native'; import { connect } from 'react-redux'; import parse from 'url-parse'; -import moment from 'moment'; import { Q } from '@nozbe/watermelondb'; import { dequal } from 'dequal'; import { withSafeAreaInsets } from 'react-native-safe-area-context'; import { Subscription } from 'rxjs'; import * as Haptics from 'expo-haptics'; +import dayjs from '../../lib/dayjs'; import { getRoutingConfig, getUserInfo, @@ -1296,11 +1296,11 @@ class RoomView extends React.Component { if (!previousItem) { dateSeparator = item.ts; - showUnreadSeparator = moment(item.ts).isAfter(lastOpen); + showUnreadSeparator = dayjs(item.ts).isAfter(lastOpen); } else { showUnreadSeparator = - (lastOpen && moment(item.ts).isSameOrAfter(lastOpen) && moment(previousItem.ts).isBefore(lastOpen)) ?? false; - if (!moment(item.ts).isSame(previousItem.ts, 'day')) { + (lastOpen && (dayjs(item.ts).isSame(lastOpen) || dayjs(item.ts).isAfter(lastOpen)) && dayjs(previousItem.ts).isBefore(lastOpen)) ?? false; + if (!dayjs(item.ts).isSame(previousItem.ts, 'day')) { dateSeparator = item.ts; } } diff --git a/package.json b/package.json index f6a01974cf0..e5376df0163 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "@rocket.chat/ui-kit": "0.31.19", "bytebuffer": "5.0.1", "color2k": "1.2.4", + "dayjs": "^1.11.18", "dequal": "2.0.3", "ejson": "2.2.3", "eslint-import-resolver-typescript": "^4.4.4", diff --git a/yarn.lock b/yarn.lock index b7f53c6362e..2d372b1796c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7388,6 +7388,11 @@ data-view-byte-offset@^1.0.0: es-errors "^1.3.0" is-data-view "^1.0.1" +dayjs@^1.11.18: + version "1.11.18" + resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.18.tgz#835fa712aac52ab9dec8b1494098774ed7070a11" + integrity sha512-zFBQ7WFRvVRhKcWoUh+ZA1g2HVgUbsZm9sbddh8EC5iv93sui8DVVz1Npvz+r6meo9VKfa8NyLWBsQK1VvIKPA== + dayjs@^1.8.15: version "1.11.10" resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.10.tgz#68acea85317a6e164457d6d6947564029a6a16a0" From 1fb0b65f1fdaa819f2516fa2ed91344042d354e6 Mon Sep 17 00:00:00 2001 From: Rohit Bansal <40559587+Rohit3523@users.noreply.github.com> Date: Tue, 14 Oct 2025 02:55:52 +0530 Subject: [PATCH 02/10] removed moment --- package.json | 1 - yarn.lock | 5 ----- 2 files changed, 6 deletions(-) diff --git a/package.json b/package.json index e5376df0163..0844c1a1fff 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,6 @@ "lint-staged": "11.1.0", "lodash": "4.17.21", "mitt": "3.0.1", - "moment": "2.29.4", "pretty-bytes": "5.6.0", "prop-types": "15.7.2", "react": "19.0.0", diff --git a/yarn.lock b/yarn.lock index 2d372b1796c..def189644c0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11780,11 +11780,6 @@ mkdirp@^3.0.1: resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-3.0.1.tgz#e44e4c5607fb279c168241713cc6e0fea9adcb50" integrity sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg== -moment@2.29.4: - version "2.29.4" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108" - integrity sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w== - moment@2.x.x, moment@^2.19.3: version "2.30.1" resolved "https://registry.yarnpkg.com/moment/-/moment-2.30.1.tgz#f8c91c07b7a786e30c59926df530b4eac96974ae" From 5791c2f47ec4705cff881b8bc45e699ea4c85cba Mon Sep 17 00:00:00 2001 From: Rohit3523 Date: Mon, 13 Oct 2025 21:28:15 +0000 Subject: [PATCH 03/10] chore: format code with Prettier [skip ci] --- app/i18n/dayjs.ts | 34 +++++++++++++++++----------------- app/lib/dayjs/index.ts | 2 +- app/views/RoomView/index.tsx | 5 ++++- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/app/i18n/dayjs.ts b/app/i18n/dayjs.ts index 69c33417758..42274fbc912 100644 --- a/app/i18n/dayjs.ts +++ b/app/i18n/dayjs.ts @@ -1,21 +1,21 @@ const localeKeys: { [key: string]: string } = { - en: 'en', - ar: 'ar', - de: 'de', - 'es-ES': 'es', - fi: 'fi', - fr: 'fr', - it: 'it', - ja: 'ja', - nl: 'nl', - 'pt-BR': 'pt-br', - 'pt-PT': 'pt', - ru: 'ru', - 'sl-SI': 'sl', - sv: 'sv', - tr: 'tr', - 'zh-CN': 'zh-cn', - 'zh-TW': 'zh-tw' + en: 'en', + ar: 'ar', + de: 'de', + 'es-ES': 'es', + fi: 'fi', + fr: 'fr', + it: 'it', + ja: 'ja', + nl: 'nl', + 'pt-BR': 'pt-br', + 'pt-PT': 'pt', + ru: 'ru', + 'sl-SI': 'sl', + sv: 'sv', + tr: 'tr', + 'zh-CN': 'zh-cn', + 'zh-TW': 'zh-tw' }; export const toDayJsLocale = (locale: string): string => localeKeys[locale] || locale; diff --git a/app/lib/dayjs/index.ts b/app/lib/dayjs/index.ts index 9d881d2d888..0e45e3d7799 100644 --- a/app/lib/dayjs/index.ts +++ b/app/lib/dayjs/index.ts @@ -35,4 +35,4 @@ dayjs.extend(timezone); dayjs.extend(calendar); dayjs.extend(relativeTime); -export default dayjs; \ No newline at end of file +export default dayjs; diff --git a/app/views/RoomView/index.tsx b/app/views/RoomView/index.tsx index 593a74b545a..be3bfceb999 100644 --- a/app/views/RoomView/index.tsx +++ b/app/views/RoomView/index.tsx @@ -1299,7 +1299,10 @@ class RoomView extends React.Component { showUnreadSeparator = dayjs(item.ts).isAfter(lastOpen); } else { showUnreadSeparator = - (lastOpen && (dayjs(item.ts).isSame(lastOpen) || dayjs(item.ts).isAfter(lastOpen)) && dayjs(previousItem.ts).isBefore(lastOpen)) ?? false; + (lastOpen && + (dayjs(item.ts).isSame(lastOpen) || dayjs(item.ts).isAfter(lastOpen)) && + dayjs(previousItem.ts).isBefore(lastOpen)) ?? + false; if (!dayjs(item.ts).isSame(previousItem.ts, 'day')) { dateSeparator = item.ts; } From 193091ba2c98591a69144daa7ef22b6796f47a22 Mon Sep 17 00:00:00 2001 From: Rohit Bansal <40559587+Rohit3523@users.noreply.github.com> Date: Tue, 14 Oct 2025 17:23:36 +0530 Subject: [PATCH 04/10] lint fix --- app/lib/methods/AudioManager.ts | 2 +- app/lib/methods/checkSupportedVersions.ts | 2 +- app/lib/methods/getServerInfo.ts | 2 +- app/lib/methods/helpers/localAuthentication.ts | 2 +- app/lib/methods/helpers/normalizeMessage.ts | 2 +- app/lib/methods/helpers/room.ts | 2 +- app/lib/methods/loadMessagesForRoom.ts | 2 +- app/lib/methods/loadNextMessages.ts | 2 +- app/lib/methods/loadSurroundingMessages.ts | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/lib/methods/AudioManager.ts b/app/lib/methods/AudioManager.ts index d0917f0030e..5bf4a526059 100644 --- a/app/lib/methods/AudioManager.ts +++ b/app/lib/methods/AudioManager.ts @@ -1,7 +1,7 @@ import { AVPlaybackStatus, Audio } from 'expo-av'; import { Q } from '@nozbe/watermelondb'; -import dayjs from '../../lib/dayjs'; +import dayjs from "../dayjs"; import { getMessageById } from '../database/services/Message'; import database from '../database'; import { getFilePathAudio } from './getFilePathAudio'; diff --git a/app/lib/methods/checkSupportedVersions.ts b/app/lib/methods/checkSupportedVersions.ts index a5e0b733cf6..c73f026ff6d 100644 --- a/app/lib/methods/checkSupportedVersions.ts +++ b/app/lib/methods/checkSupportedVersions.ts @@ -1,7 +1,7 @@ import coerce from 'semver/functions/coerce'; import satisfies from 'semver/functions/satisfies'; -import dayjs from '../../lib/dayjs'; +import dayjs from "../dayjs"; import { ISupportedVersionsData, TSVDictionary, TSVMessage, TSVStatus } from '../../definitions'; import builtInSupportedVersions from '../../../app-supportedversions.json'; diff --git a/app/lib/methods/getServerInfo.ts b/app/lib/methods/getServerInfo.ts index f52d89ce147..41507c6fca4 100644 --- a/app/lib/methods/getServerInfo.ts +++ b/app/lib/methods/getServerInfo.ts @@ -1,6 +1,6 @@ import { KJUR } from 'jsrsasign'; -import dayjs from '../../lib/dayjs'; +import dayjs from "../dayjs"; import { getSupportedVersionsCloud } from '../services/restApi'; import { TCloudInfo, IServerInfo, ISupportedVersions, ISupportedVersionsData, IApiServerInfo } from '../../definitions'; import { selectServerFailure } from '../../actions/server'; diff --git a/app/lib/methods/helpers/localAuthentication.ts b/app/lib/methods/helpers/localAuthentication.ts index 1921dda39f1..cb758069005 100644 --- a/app/lib/methods/helpers/localAuthentication.ts +++ b/app/lib/methods/helpers/localAuthentication.ts @@ -3,7 +3,7 @@ import RNBootSplash from 'react-native-bootsplash'; import AsyncStorage from '@react-native-async-storage/async-storage'; import { sha256 } from 'js-sha256'; -import dayjs from '../../../lib/dayjs'; +import dayjs from "../../dayjs"; import UserPreferences from '../userPreferences'; import { store } from '../../store/auxStore'; import database from '../../database'; diff --git a/app/lib/methods/helpers/normalizeMessage.ts b/app/lib/methods/helpers/normalizeMessage.ts index 8237ee9b92e..7367d303107 100644 --- a/app/lib/methods/helpers/normalizeMessage.ts +++ b/app/lib/methods/helpers/normalizeMessage.ts @@ -1,4 +1,4 @@ -import dayjs from '../../../lib/dayjs'; +import dayjs from "../../dayjs"; import parseUrls from './parseUrls'; import type { IAttachment, IMessage, IThreadResult } from '../../../definitions'; diff --git a/app/lib/methods/helpers/room.ts b/app/lib/methods/helpers/room.ts index 0713868f100..6f9ca9fb176 100644 --- a/app/lib/methods/helpers/room.ts +++ b/app/lib/methods/helpers/room.ts @@ -1,4 +1,4 @@ -import dayjs from '../../../lib/dayjs'; +import dayjs from "../../dayjs"; import { themes } from '../../constants/colors'; import I18n from '../../../i18n'; import { IAttachment, SubscriptionType, TSubscriptionModel } from '../../../definitions'; diff --git a/app/lib/methods/loadMessagesForRoom.ts b/app/lib/methods/loadMessagesForRoom.ts index 78bdba44547..2513db30304 100644 --- a/app/lib/methods/loadMessagesForRoom.ts +++ b/app/lib/methods/loadMessagesForRoom.ts @@ -1,4 +1,4 @@ -import dayjs from '../../lib/dayjs'; +import dayjs from "../dayjs"; import { MessageTypeLoad } from '../constants/messageTypeLoad'; import { IMessage, TMessageModel } from '../../definitions'; import log from './helpers/log'; diff --git a/app/lib/methods/loadNextMessages.ts b/app/lib/methods/loadNextMessages.ts index a182cf4f7c1..ac6b5b90924 100644 --- a/app/lib/methods/loadNextMessages.ts +++ b/app/lib/methods/loadNextMessages.ts @@ -1,7 +1,7 @@ import EJSON from 'ejson'; import orderBy from 'lodash/orderBy'; -import dayjs from '../../lib/dayjs'; +import dayjs from "../dayjs"; import log from './helpers/log'; import { getMessageById } from '../database/services/Message'; import { MessageTypeLoad } from '../constants/messageTypeLoad'; diff --git a/app/lib/methods/loadSurroundingMessages.ts b/app/lib/methods/loadSurroundingMessages.ts index 589af6cc0a0..88234335008 100644 --- a/app/lib/methods/loadSurroundingMessages.ts +++ b/app/lib/methods/loadSurroundingMessages.ts @@ -1,7 +1,7 @@ import EJSON from 'ejson'; import orderBy from 'lodash/orderBy'; -import dayjs from '../../lib/dayjs'; +import dayjs from "../dayjs"; import log from './helpers/log'; import { getMessageById } from '../database/services/Message'; import { MessageTypeLoad } from '../constants/messageTypeLoad'; From 55dbc2f0d43160c63b5beedb33823b84b55bf6a4 Mon Sep 17 00:00:00 2001 From: Rohit3523 Date: Tue, 14 Oct 2025 11:54:43 +0000 Subject: [PATCH 05/10] chore: format code with Prettier [skip ci] --- app/lib/methods/AudioManager.ts | 2 +- app/lib/methods/checkSupportedVersions.ts | 2 +- app/lib/methods/getServerInfo.ts | 2 +- app/lib/methods/helpers/localAuthentication.ts | 2 +- app/lib/methods/helpers/normalizeMessage.ts | 2 +- app/lib/methods/helpers/room.ts | 2 +- app/lib/methods/loadMessagesForRoom.ts | 2 +- app/lib/methods/loadNextMessages.ts | 2 +- app/lib/methods/loadSurroundingMessages.ts | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/lib/methods/AudioManager.ts b/app/lib/methods/AudioManager.ts index 5bf4a526059..a151e9ffbe3 100644 --- a/app/lib/methods/AudioManager.ts +++ b/app/lib/methods/AudioManager.ts @@ -1,7 +1,7 @@ import { AVPlaybackStatus, Audio } from 'expo-av'; import { Q } from '@nozbe/watermelondb'; -import dayjs from "../dayjs"; +import dayjs from '../dayjs'; import { getMessageById } from '../database/services/Message'; import database from '../database'; import { getFilePathAudio } from './getFilePathAudio'; diff --git a/app/lib/methods/checkSupportedVersions.ts b/app/lib/methods/checkSupportedVersions.ts index c73f026ff6d..2d3a5da042d 100644 --- a/app/lib/methods/checkSupportedVersions.ts +++ b/app/lib/methods/checkSupportedVersions.ts @@ -1,7 +1,7 @@ import coerce from 'semver/functions/coerce'; import satisfies from 'semver/functions/satisfies'; -import dayjs from "../dayjs"; +import dayjs from '../dayjs'; import { ISupportedVersionsData, TSVDictionary, TSVMessage, TSVStatus } from '../../definitions'; import builtInSupportedVersions from '../../../app-supportedversions.json'; diff --git a/app/lib/methods/getServerInfo.ts b/app/lib/methods/getServerInfo.ts index 41507c6fca4..9ad33d2362f 100644 --- a/app/lib/methods/getServerInfo.ts +++ b/app/lib/methods/getServerInfo.ts @@ -1,6 +1,6 @@ import { KJUR } from 'jsrsasign'; -import dayjs from "../dayjs"; +import dayjs from '../dayjs'; import { getSupportedVersionsCloud } from '../services/restApi'; import { TCloudInfo, IServerInfo, ISupportedVersions, ISupportedVersionsData, IApiServerInfo } from '../../definitions'; import { selectServerFailure } from '../../actions/server'; diff --git a/app/lib/methods/helpers/localAuthentication.ts b/app/lib/methods/helpers/localAuthentication.ts index cb758069005..1822803b7ba 100644 --- a/app/lib/methods/helpers/localAuthentication.ts +++ b/app/lib/methods/helpers/localAuthentication.ts @@ -3,7 +3,7 @@ import RNBootSplash from 'react-native-bootsplash'; import AsyncStorage from '@react-native-async-storage/async-storage'; import { sha256 } from 'js-sha256'; -import dayjs from "../../dayjs"; +import dayjs from '../../dayjs'; import UserPreferences from '../userPreferences'; import { store } from '../../store/auxStore'; import database from '../../database'; diff --git a/app/lib/methods/helpers/normalizeMessage.ts b/app/lib/methods/helpers/normalizeMessage.ts index 7367d303107..e5bf66d0e10 100644 --- a/app/lib/methods/helpers/normalizeMessage.ts +++ b/app/lib/methods/helpers/normalizeMessage.ts @@ -1,4 +1,4 @@ -import dayjs from "../../dayjs"; +import dayjs from '../../dayjs'; import parseUrls from './parseUrls'; import type { IAttachment, IMessage, IThreadResult } from '../../../definitions'; diff --git a/app/lib/methods/helpers/room.ts b/app/lib/methods/helpers/room.ts index 6f9ca9fb176..8bd5ecd71b1 100644 --- a/app/lib/methods/helpers/room.ts +++ b/app/lib/methods/helpers/room.ts @@ -1,4 +1,4 @@ -import dayjs from "../../dayjs"; +import dayjs from '../../dayjs'; import { themes } from '../../constants/colors'; import I18n from '../../../i18n'; import { IAttachment, SubscriptionType, TSubscriptionModel } from '../../../definitions'; diff --git a/app/lib/methods/loadMessagesForRoom.ts b/app/lib/methods/loadMessagesForRoom.ts index 2513db30304..7d41427b3b8 100644 --- a/app/lib/methods/loadMessagesForRoom.ts +++ b/app/lib/methods/loadMessagesForRoom.ts @@ -1,4 +1,4 @@ -import dayjs from "../dayjs"; +import dayjs from '../dayjs'; import { MessageTypeLoad } from '../constants/messageTypeLoad'; import { IMessage, TMessageModel } from '../../definitions'; import log from './helpers/log'; diff --git a/app/lib/methods/loadNextMessages.ts b/app/lib/methods/loadNextMessages.ts index ac6b5b90924..06d72e0aa96 100644 --- a/app/lib/methods/loadNextMessages.ts +++ b/app/lib/methods/loadNextMessages.ts @@ -1,7 +1,7 @@ import EJSON from 'ejson'; import orderBy from 'lodash/orderBy'; -import dayjs from "../dayjs"; +import dayjs from '../dayjs'; import log from './helpers/log'; import { getMessageById } from '../database/services/Message'; import { MessageTypeLoad } from '../constants/messageTypeLoad'; diff --git a/app/lib/methods/loadSurroundingMessages.ts b/app/lib/methods/loadSurroundingMessages.ts index 88234335008..9c0567bbd1c 100644 --- a/app/lib/methods/loadSurroundingMessages.ts +++ b/app/lib/methods/loadSurroundingMessages.ts @@ -1,7 +1,7 @@ import EJSON from 'ejson'; import orderBy from 'lodash/orderBy'; -import dayjs from "../dayjs"; +import dayjs from '../dayjs'; import log from './helpers/log'; import { getMessageById } from '../database/services/Message'; import { MessageTypeLoad } from '../constants/messageTypeLoad'; From 790fd3c170da7c8fe1b4b5d415283eff37a4b23c Mon Sep 17 00:00:00 2001 From: Rohit Bansal <40559587+Rohit3523@users.noreply.github.com> Date: Tue, 14 Oct 2025 17:37:14 +0530 Subject: [PATCH 06/10] Added localizedFormat --- app/lib/dayjs/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/lib/dayjs/index.ts b/app/lib/dayjs/index.ts index 0e45e3d7799..f492c042909 100644 --- a/app/lib/dayjs/index.ts +++ b/app/lib/dayjs/index.ts @@ -3,6 +3,7 @@ import utc from 'dayjs/plugin/utc'; import timezone from 'dayjs/plugin/timezone'; import calendar from 'dayjs/plugin/calendar'; import relativeTime from 'dayjs/plugin/relativeTime'; +import localizedFormat from 'dayjs/plugin/localizedFormat'; import 'dayjs/locale/en'; import 'dayjs/locale/ar'; @@ -34,5 +35,6 @@ dayjs.extend(utc); dayjs.extend(timezone); dayjs.extend(calendar); dayjs.extend(relativeTime); +dayjs.extend(localizedFormat); export default dayjs; From 382746d2da1c4c5bfcde7ac9cd701812f480dbac Mon Sep 17 00:00:00 2001 From: Rohit Bansal <40559587+Rohit3523@users.noreply.github.com> Date: Tue, 14 Oct 2025 19:02:00 +0530 Subject: [PATCH 07/10] handle null condition --- app/views/RoomView/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/RoomView/index.tsx b/app/views/RoomView/index.tsx index be3bfceb999..7417ab1e7a5 100644 --- a/app/views/RoomView/index.tsx +++ b/app/views/RoomView/index.tsx @@ -1296,7 +1296,7 @@ class RoomView extends React.Component { if (!previousItem) { dateSeparator = item.ts; - showUnreadSeparator = dayjs(item.ts).isAfter(lastOpen); + showUnreadSeparator = lastOpen ? dayjs(item.ts).isAfter(lastOpen) : false; } else { showUnreadSeparator = (lastOpen && From 3722ab355a7823b265d75dbe06421a969da1dd31 Mon Sep 17 00:00:00 2001 From: Rohit Bansal <40559587+Rohit3523@users.noreply.github.com> Date: Tue, 14 Oct 2025 19:03:26 +0530 Subject: [PATCH 08/10] added no key in dayjs locale --- app/i18n/dayjs.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/i18n/dayjs.ts b/app/i18n/dayjs.ts index 42274fbc912..4dfbd7e88fc 100644 --- a/app/i18n/dayjs.ts +++ b/app/i18n/dayjs.ts @@ -15,7 +15,8 @@ const localeKeys: { [key: string]: string } = { sv: 'sv', tr: 'tr', 'zh-CN': 'zh-cn', - 'zh-TW': 'zh-tw' + 'zh-TW': 'zh-tw', + 'no': 'nb' }; export const toDayJsLocale = (locale: string): string => localeKeys[locale] || locale; From 3a245d2c849b0d4442247cab85bf1820c5c6e0dd Mon Sep 17 00:00:00 2001 From: Rohit3523 Date: Tue, 14 Oct 2025 13:34:49 +0000 Subject: [PATCH 09/10] chore: format code with Prettier [skip ci] --- app/i18n/dayjs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/i18n/dayjs.ts b/app/i18n/dayjs.ts index 4dfbd7e88fc..32879525694 100644 --- a/app/i18n/dayjs.ts +++ b/app/i18n/dayjs.ts @@ -16,7 +16,7 @@ const localeKeys: { [key: string]: string } = { tr: 'tr', 'zh-CN': 'zh-cn', 'zh-TW': 'zh-tw', - 'no': 'nb' + no: 'nb' }; export const toDayJsLocale = (locale: string): string => localeKeys[locale] || locale; From 004b2b1a1e40b246402dd1418686fe59842d1bde Mon Sep 17 00:00:00 2001 From: Rohit Bansal <40559587+Rohit3523@users.noreply.github.com> Date: Tue, 14 Oct 2025 19:08:41 +0530 Subject: [PATCH 10/10] added millisecond in passcord --- app/containers/Passcode/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/containers/Passcode/utils.ts b/app/containers/Passcode/utils.ts index c0bb39f3ef4..8a07b6dbbb4 100644 --- a/app/containers/Passcode/utils.ts +++ b/app/containers/Passcode/utils.ts @@ -6,7 +6,7 @@ import { LOCKED_OUT_TIMER_KEY, TIME_TO_LOCK } from '../../lib/constants/localAut export const getLockedUntil = async () => { const t = await AsyncStorage.getItem(LOCKED_OUT_TIMER_KEY); if (t) { - return dayjs(t).add(TIME_TO_LOCK).toDate(); + return dayjs(t).add(TIME_TO_LOCK, 'millisecond').toDate(); } return null; };