mattermost-mobile/app/components/post_list/post/avatar/index.ts
Daniel Espino García 7c642b1e80
[Gekidou] Extract common observers to queries (#5984)
* Extract common observers to queries

* Separate also queries and more agressive refactoring

* Use query to avoid throws from findAndObserve

* Fix minor error

* Address feedback

* Address feedback

* Address feedback

* Fix model types

* Address feedback
2022-03-23 09:19:29 -03:00

23 lines
802 B
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {withDatabase} from '@nozbe/watermelondb/DatabaseProvider';
import enhance from '@nozbe/with-observables';
import {observeConfigBooleanValue} from '@queries/servers/system';
import Avatar from './avatar';
import type {WithDatabaseArgs} from '@typings/database/database';
import type PostModel from '@typings/database/models/servers/post';
const withPost = enhance(['post'], ({database, post}: {post: PostModel} & WithDatabaseArgs) => {
const enablePostIconOverride = observeConfigBooleanValue(database, 'EnablePostIconOverride');
return {
author: post.author.observe(),
enablePostIconOverride,
};
});
export default withDatabase(withPost(Avatar));