From da8f9c3c731d7511b59b994e47762d6f0770b554 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 19 Nov 2022 22:53:33 +0300 Subject: Moment -> Day.js --- vnext/src/ui/Chat.js | 6 ++++-- vnext/src/ui/Feeds.js | 6 ++++-- vnext/src/ui/Message.js | 10 +++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) (limited to 'vnext/src/ui') diff --git a/vnext/src/ui/Chat.js b/vnext/src/ui/Chat.js index 2a3e90de..c1151daf 100644 --- a/vnext/src/ui/Chat.js +++ b/vnext/src/ui/Chat.js @@ -1,6 +1,8 @@ import { useEffect, useState, useCallback } from 'react'; import { useParams } from 'react-router-dom'; -import moment from 'moment'; +import dayjs from 'dayjs'; +import utc from 'dayjs/plugin/utc'; +dayjs.extend(utc); import PM from './PM'; import MessageInput from './MessageInput'; @@ -77,7 +79,7 @@ export default function Chat(props) { diff --git a/vnext/src/ui/Feeds.js b/vnext/src/ui/Feeds.js index fc402583..2019dffd 100644 --- a/vnext/src/ui/Feeds.js +++ b/vnext/src/ui/Feeds.js @@ -2,7 +2,9 @@ import { useState, useEffect } from 'react'; import { Link, useLocation, useParams, Navigate } from 'react-router-dom'; import qs from 'qs'; -import moment from 'moment'; +import dayjs from 'dayjs'; +import utc from 'dayjs/plugin/utc'; +dayjs.extend(utc); import Message from './Message'; import Spinner from './Spinner'; @@ -171,7 +173,7 @@ function Feed({ query }) { setLoading(true); const filter = location.search.substring(1); let getPageParam = (pageParam, lastMessage, filterParams) => { - const pageValue = pageParam === 'before_mid' ? lastMessage.mid : pageParam === 'page' ? (Number(filterParams.page) || 0) + 1 : moment.utc(lastMessage.updated).valueOf(); + const pageValue = pageParam === 'before_mid' ? lastMessage.mid : pageParam === 'page' ? (Number(filterParams.page) || 0) + 1 : dayjs.utc(lastMessage.updated).valueOf(); let newFilter = { ...filterParams }; newFilter[pageParam] = pageValue; return `?${qs.stringify(newFilter)}`; diff --git a/vnext/src/ui/Message.js b/vnext/src/ui/Message.js index 581ede55..d45395bb 100644 --- a/vnext/src/ui/Message.js +++ b/vnext/src/ui/Message.js @@ -1,6 +1,10 @@ import React, { Fragment, memo, useEffect, useRef } from 'react'; -import moment from 'moment'; +import dayjs from 'dayjs'; +import utc from 'dayjs/plugin/utc'; +dayjs.extend(utc); +import relativeTime from 'dayjs/plugin/relativeTime'; +dayjs.extend(relativeTime); import { Link } from 'react-router-dom'; import Icon from './Icon'; @@ -54,8 +58,8 @@ export default function Message({ data, children }) {
{ -- cgit v1.2.3