Fix undefined value checks in use_http_client_2 (#1230)

* fix: filter out undefined from posts

* fix: emoji initialisation passing undefined

* fix: || => ?? to be more explicit

* linting

---------

Co-authored-by: Alex Maras <alexmaras@gmail.com>
This commit is contained in:
Alex Maras 2023-06-13 23:02:46 +08:00 committed by GitHub
parent 2529322afd
commit 1877f653f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -115,7 +115,7 @@ export class PostListings extends Component<PostListingsProps, any> {
removeDuplicates(): PostView[] {
// Must use a spread to clone the props, because splice will fail below otherwise.
const posts = [...this.props.posts];
const posts = [...this.props.posts].filter(empty => empty);
// A map from post url to list of posts (dupes)
const urlMap = new Map<string, PostView[]>();

View file

@ -1274,7 +1274,7 @@ export function initializeSite(site?: GetSiteResponse) {
UserService.Instance.myUserInfo = site?.my_user;
i18n.changeLanguage(getLanguages()[0]);
if (site) {
setupEmojiDataModel(site.custom_emojis);
setupEmojiDataModel(site.custom_emojis ?? []);
}
setupMarkdown();
}