Repository navigation
chore: migrate from momentjs to dayjs #6724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
009b565
1fb0b65
5791c2f
b88297e
193091b
55dbc2f
790fd3c
382746d
3722ab3
3a245d2
004b2b1
eab2bdf
2043bfb
d8beb0b
f282e9a
49cdc05
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| 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 localizedFormat from 'dayjs/plugin/localizedFormat'; | ||
|
|
||
| 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); | ||
| dayjs.extend(localizedFormat); | ||
|
|
||
| export default dayjs; |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,7 @@ | ||||||||||
| import EJSON from 'ejson'; | ||||||||||
| import moment from 'moment'; | ||||||||||
| import orderBy from 'lodash/orderBy'; | ||||||||||
|
|
||||||||||
| import dayjs from '../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<void> { | |||||||||
| 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 | ||||||||||
|
Comment on lines
+34
to
35
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ts should be a Date; missing toDate() (bug). You’re pushing a Day.js instance instead of a Date. Align with loadSurroundingMessages and consumers’ expectations. - ts: dayjs(lastMessage.ts).add(1, 'millisecond'),
+ ts: dayjs(lastMessage.ts).add(1, 'millisecond').toDate(),📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| }; | ||||||||||
| messages.push(loadMoreItem); | ||||||||||
|
|
||||||||||
Uh oh!
There was an error while loading. Please reload this page.