mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-26 00:50:56 -05:00
Simplify how last message is handled.
This commit is contained in:
parent
45c7cd0307
commit
cc45b9e255
4 changed files with 12 additions and 25 deletions
|
@ -121,7 +121,7 @@
|
||||||
"react-virtuoso": "^1.10.4",
|
"react-virtuoso": "^1.10.4",
|
||||||
"redux": "^4.1.0",
|
"redux": "^4.1.0",
|
||||||
"revolt-api": "0.5.3-alpha.0-patch.0",
|
"revolt-api": "0.5.3-alpha.0-patch.0",
|
||||||
"revolt.js": "5.1.0-alpha.0-patch.1",
|
"revolt.js": "5.1.0-alpha.1",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"sass": "^1.35.1",
|
"sass": "^1.35.1",
|
||||||
"shade-blend-color": "^1.0.0",
|
"shade-blend-color": "^1.0.0",
|
||||||
|
|
|
@ -82,8 +82,9 @@ export const UserButton = observer((props: UserProps) => {
|
||||||
</div>
|
</div>
|
||||||
{
|
{
|
||||||
<div className={styles.subText}>
|
<div className={styles.subText}>
|
||||||
{channel?.last_message && alert ? (
|
{typeof channel?.last_message?.content === "string" &&
|
||||||
(channel.last_message as { short: string }).short
|
alert ? (
|
||||||
|
channel.last_message.content.slice(0, 32)
|
||||||
) : (
|
) : (
|
||||||
<UserStatus user={user} />
|
<UserStatus user={user} />
|
||||||
)}
|
)}
|
||||||
|
@ -162,8 +163,9 @@ export const ChannelButton = observer((props: ChannelProps) => {
|
||||||
<div>{channel.name}</div>
|
<div>{channel.name}</div>
|
||||||
{channel.channel_type === "Group" && (
|
{channel.channel_type === "Group" && (
|
||||||
<div className={styles.subText}>
|
<div className={styles.subText}>
|
||||||
{channel.last_message && alert ? (
|
{typeof channel.last_message?.content === "string" &&
|
||||||
(channel.last_message as { short: string }).short
|
alert ? (
|
||||||
|
channel.last_message.content.slice(0, 32)
|
||||||
) : (
|
) : (
|
||||||
<Text
|
<Text
|
||||||
id="quantities.members"
|
id="quantities.members"
|
||||||
|
|
|
@ -49,22 +49,7 @@ export function useUnreads({ channel, unreads }: UnreadProps) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mapChannelWithUnread(channel: Channel, unreads: Unreads) {
|
export function mapChannelWithUnread(channel: Channel, unreads: Unreads) {
|
||||||
let last_message_id;
|
const last_message_id = channel.last_message_id;
|
||||||
if (
|
|
||||||
channel.channel_type === "DirectMessage" ||
|
|
||||||
channel.channel_type === "Group"
|
|
||||||
) {
|
|
||||||
last_message_id = (channel.last_message as { _id: string })?._id;
|
|
||||||
} else if (channel.channel_type === "TextChannel") {
|
|
||||||
last_message_id = channel.last_message as string;
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
channel,
|
|
||||||
unread: undefined,
|
|
||||||
alertCount: undefined,
|
|
||||||
timestamp: channel._id,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
let unread: "mention" | "unread" | undefined;
|
let unread: "mention" | "unread" | undefined;
|
||||||
let alertCount: undefined | number;
|
let alertCount: undefined | number;
|
||||||
|
|
|
@ -3659,10 +3659,10 @@ revolt-api@0.5.3-alpha.0-patch.0:
|
||||||
resolved "https://registry.yarnpkg.com/revolt-api/-/revolt-api-0.5.3-alpha.0-patch.0.tgz#158556832843bb06cb06a4df50ffca24ab64be3b"
|
resolved "https://registry.yarnpkg.com/revolt-api/-/revolt-api-0.5.3-alpha.0-patch.0.tgz#158556832843bb06cb06a4df50ffca24ab64be3b"
|
||||||
integrity sha512-76l+kGyrUy6uGMSIziyAHE27r9gD97OEh5gSzb2OJRsQM55TN0NurAsfFIEiB9hUzDDlwsXchtJiqdS4UVAwQw==
|
integrity sha512-76l+kGyrUy6uGMSIziyAHE27r9gD97OEh5gSzb2OJRsQM55TN0NurAsfFIEiB9hUzDDlwsXchtJiqdS4UVAwQw==
|
||||||
|
|
||||||
revolt.js@5.1.0-alpha.0-patch.1:
|
revolt.js@5.1.0-alpha.1:
|
||||||
version "5.1.0-alpha.0-patch.1"
|
version "5.1.0-alpha.1"
|
||||||
resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.1.0-alpha.0-patch.1.tgz#68fd28af78a8b0b60cc2ed3523d8e9fbfa15a903"
|
resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.1.0-alpha.1.tgz#0ac89eb67bb217ba270f3d3d5aa00621c9e69904"
|
||||||
integrity sha512-VanPjG6vZGoFGNfRFGyj7PTstJeniE/Fly5KNhz7bTIzHkxn7xtsLEE+EKeEpZY4Y9km+l09qav1/VfIZUm9NA==
|
integrity sha512-90B6QgfccvPDKu2vlZr2vxofkqWCHpdHrDTdieA0SkgIFZ0rJ+zIMv7YbWCToA+sh6OppH+7I5MP3suHs3AtSA==
|
||||||
dependencies:
|
dependencies:
|
||||||
axios "^0.19.2"
|
axios "^0.19.2"
|
||||||
eventemitter3 "^4.0.7"
|
eventemitter3 "^4.0.7"
|
||||||
|
|
Loading…
Reference in a new issue