aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-11-19 22:53:33 +0300
committerGravatar Vitaly Takmazov2023-01-13 10:37:59 +0300
commitda8f9c3c731d7511b59b994e47762d6f0770b554 (patch)
tree695b3202e8cbbac1d88cac7ca9cce9f4e0b5ab26
parenta8c7596c03ab69f5752c2d94a14160c5bc922309 (diff)
Moment -> Day.js
-rw-r--r--vnext/package-lock.json25
-rw-r--r--vnext/package.json2
-rw-r--r--vnext/src/ui/Chat.js6
-rw-r--r--vnext/src/ui/Feeds.js6
-rw-r--r--vnext/src/ui/Message.js10
5 files changed, 27 insertions, 22 deletions
diff --git a/vnext/package-lock.json b/vnext/package-lock.json
index 237a10b7..8257642c 100644
--- a/vnext/package-lock.json
+++ b/vnext/package-lock.json
@@ -15,12 +15,12 @@
"config": "^3.3.8",
"core-js": "^3.26.1",
"cors": "^2.8.5",
+ "dayjs": "^1.11.6",
"esbuild": "^0.15.14",
"evil-icons": "^1.10.1",
"express": "^4.18.2",
"ignore-styles": "^5.0.1",
"mailparser": "^3.5.0",
- "moment": "^2.29.4",
"node-pushnotifications": "^2.0.3",
"qs": "^6.11.0",
"react": "18.2.0",
@@ -5201,6 +5201,11 @@
"url": "https://opencollective.com/date-fns"
}
},
+ "node_modules/dayjs": {
+ "version": "1.11.6",
+ "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.6.tgz",
+ "integrity": "sha512-zZbY5giJAinCG+7AGaw0wIhNZ6J8AhWuSXKvuc1KAyMiRsvGQWqh4L+MomvhdAYjN+lqvVCMq1I41e3YHvXkyQ=="
+ },
"node_modules/debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
@@ -11786,14 +11791,6 @@
"node": ">=0.10.0"
}
},
- "node_modules/moment": {
- "version": "2.29.4",
- "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
- "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==",
- "engines": {
- "node": "*"
- }
- },
"node_modules/moo": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/moo/-/moo-0.5.2.tgz",
@@ -20936,6 +20933,11 @@
"integrity": "sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA==",
"dev": true
},
+ "dayjs": {
+ "version": "1.11.6",
+ "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.6.tgz",
+ "integrity": "sha512-zZbY5giJAinCG+7AGaw0wIhNZ6J8AhWuSXKvuc1KAyMiRsvGQWqh4L+MomvhdAYjN+lqvVCMq1I41e3YHvXkyQ=="
+ },
"debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
@@ -25793,11 +25795,6 @@
}
}
},
- "moment": {
- "version": "2.29.4",
- "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
- "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w=="
- },
"moo": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/moo/-/moo-0.5.2.tgz",
diff --git a/vnext/package.json b/vnext/package.json
index afd54d91..2582edf2 100644
--- a/vnext/package.json
+++ b/vnext/package.json
@@ -55,12 +55,12 @@
"config": "^3.3.8",
"core-js": "^3.26.1",
"cors": "^2.8.5",
+ "dayjs": "^1.11.6",
"esbuild": "^0.15.14",
"evil-icons": "^1.10.1",
"express": "^4.18.2",
"ignore-styles": "^5.0.1",
"mailparser": "^3.5.0",
- "moment": "^2.29.4",
"node-pushnotifications": "^2.0.3",
"qs": "^6.11.0",
"react": "18.2.0",
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) {
<ul className="Chat_messages">
{
chats.map((chat) =>
- <PM key={moment.utc(chat.timestamp).valueOf()} chat={chat} {...props} />
+ <PM key={dayjs.utc(chat.timestamp).valueOf()} chat={chat} {...props} />
)
}
</ul>
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 }) {
<div className="msg-ts">
<Link to={`/${data.user.uname}/${data.mid}`} state={{ data: data }}>
<time dateTime={data.timestamp}
- title={moment.utc(data.timestamp).local().format('lll')}>
- {moment.utc(data.timestamp).fromNow()}
+ title={dayjs.utc(data.timestamp).local().format('lll')}>
+ {dayjs.utc(data.timestamp).fromNow()}
</time>
</Link>
{