feat: highlight pin message

This commit is contained in:
zerosoul
2022-05-26 11:13:54 +08:00
parent 910096b55a
commit a343382b60
3 changed files with 36 additions and 4 deletions
+7
View File
@@ -25,6 +25,12 @@ export default function usePinMessage(cid = null) {
if (!mid || !cid) return;
unpin({ mid, gid: +cid });
};
const getPinInfo = (mid) => {
const pins = channel?.pinned_messages;
if (pins?.length == 0) return;
const pinned = pins.find((p) => p.mid == mid);
return pinned;
};
useEffect(() => {
if (channel) {
setPins(channel.pinned_messages);
@@ -32,6 +38,7 @@ export default function usePinMessage(cid = null) {
}, [channel]);
return {
getPinInfo,
channel,
pins,
canPin: loginUser.is_admin || channel?.owner == loginUser.uid,