Skip to content

Commit 658f527

Browse files
committed
fix: update in-app notifications to use API object
1 parent 6d19953 commit 658f527

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/MainView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function LoggedInViews({state, setChannel}: {state: any; setChannel: any}) {
9999
openChannel={() =>
100100
state.setState({
101101
notificationMessage: null,
102-
currentChannel: state.state.notificationMessage.channel,
102+
currentChannel: client.channels.get(state.state.notificationMessage.channel),
103103
})
104104
}
105105
/>
@@ -207,7 +207,7 @@ async function handleMessageNotification(
207207

208208
if (app.settings.get('app.notifications.enabled') && shouldNotif) {
209209
console.log(`[NOTIFICATIONS] Pushing notification for message ${msg._id}`);
210-
if (state.state.currentChannel !== msg.channel) {
210+
if (state.state.currentChannel !== channel) {
211211
state.setState({notificationMessage: msg});
212212
await sleep(5000);
213213
state.setState({notificationMessage: null});

src/components/Notification.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,30 @@ import {observer} from 'mobx-react-lite';
44

55
import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons';
66

7-
import type {Message} from 'revolt.js';
7+
import type {API} from 'revolt.js';
88

99
import {styles} from '../Theme';
1010
import {Avatar, Text, Username} from './common/atoms';
1111
import {MarkdownView} from './common/MarkdownView';
1212
import {commonValues, ThemeContext} from '@clerotri/lib/themes';
1313
import {parseRevoltNodes} from '../lib/utils';
14+
import { client } from '@clerotri/lib/client';
1415

1516
export const Notification = observer(
1617
({
1718
message,
1819
dismiss,
1920
openChannel,
2021
}: {
21-
message: Message | null;
22+
message: API.Message | null;
2223
dismiss: Function;
2324
openChannel: Function;
2425
}) => {
2526
const {currentTheme} = useContext(ThemeContext);
2627
if (message) {
28+
const author = client.users.get(message.author);
29+
const channel = client.channels.get(message.channel);
30+
2731
return (
2832
<TouchableOpacity
2933
style={{
@@ -42,7 +46,7 @@ export const Notification = observer(
4246
flexDirection: 'row',
4347
overflow: 'hidden',
4448
}}>
45-
<Avatar user={message.author} size={35} />
49+
<Avatar user={author} size={35} />
4650
<View
4751
style={{
4852
marginHorizontal: commonValues.sizes.medium,
@@ -54,12 +58,12 @@ export const Notification = observer(
5458
flexDirection: 'row',
5559
}}>
5660
<Username
57-
user={message.author}
58-
server={message.channel?.server}
61+
user={author}
62+
server={channel?.server}
5963
/>
6064
<Text style={{fontWeight: 'bold'}}>
6165
{' '}
62-
({message.channel?.name ?? message.channel?._id})
66+
({channel?.name ?? channel?._id})
6367
</Text>
6468
</View>
6569
{message.content ? (

0 commit comments

Comments
 (0)