PrivateMessage,
PrivateMessageResponse,
WebSocketJsonResponse,
-} from '../interfaces';
+} from 'lemmy-js-client';
import {
wsJsonToRes,
pictrsAvatarThumbnail,
showAvatars,
fetchLimit,
- isCommentType,
toast,
- messageToastify,
- md,
setTheme,
getLanguage,
+ notifyComment,
+ notifyPrivateMessage,
} from '../utils';
import { i18n } from '../i18next';
banned: [],
online: null,
version: null,
+ federated_instances: null,
},
searchParam: '',
toggleSearch: false,
this.context.router.history.push(`/search/`);
} else {
this.context.router.history.push(
- `/search/q/${searchParam}/type/all/sort/topall/page/1`
+ `/search/q/${searchParam}/type/All/sort/TopAll/page/1`
);
}
}
this.state.unreadCount++;
this.setState(this.state);
this.sendUnreadCount();
- this.notify(data.comment);
+ notifyComment(data.comment, this.context.router);
}
}
} else if (res.op == UserOperation.CreatePrivateMessage) {
this.state.unreadCount++;
this.setState(this.state);
this.sendUnreadCount();
- this.notify(data.message);
+ notifyPrivateMessage(data.message, this.context.router);
}
}
} else if (res.op == UserOperation.GetSite) {
fetchUnreads() {
console.log('Fetching unreads...');
let repliesForm: GetRepliesForm = {
- sort: SortType[SortType.New],
+ sort: SortType.New,
unread_only: true,
page: 1,
limit: fetchLimit,
};
let userMentionsForm: GetUserMentionsForm = {
- sort: SortType[SortType.New],
+ sort: SortType.New,
unread_only: true,
page: 1,
limit: fetchLimit,
});
}
}
-
- notify(reply: Comment | PrivateMessage) {
- let creator_name = reply.creator_name;
- let creator_avatar = reply.creator_avatar
- ? reply.creator_avatar
- : `${window.location.protocol}//${window.location.host}/static/assets/apple-touch-icon.png`;
- let link = isCommentType(reply)
- ? `/post/${reply.post_id}/comment/${reply.id}`
- : `/inbox`;
- let htmlBody = md.render(reply.content);
- let body = reply.content; // Unfortunately the notifications API can't do html
-
- messageToastify(
- creator_name,
- creator_avatar,
- htmlBody,
- link,
- this.context.router
- );
-
- if (Notification.permission !== 'granted') Notification.requestPermission();
- else {
- var notification = new Notification(reply.creator_name, {
- icon: creator_avatar,
- body: body,
- });
-
- notification.onclick = () => {
- event.preventDefault();
- this.context.router.history.push(link);
- };
- }
- }
}