forked from Ivasoft/mattermost-mobile
Gekidou - Sidebar - Adds actions, queries, db models and rest client (#5953)
* Adds actions, queries, db models and rest client * move fetching categories inside fetchMyChannelsForTeam * code cleanup * deconstruct categoriesWithOrder * DMs fetching for changing teams * Fix bad merge and address feedback Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
This commit is contained in:
@@ -67,19 +67,17 @@ export default class CategoryModel extends Model implements CategoryInterface {
|
||||
@children(CATEGORY_CHANNEL) categoryChannels!: Query<CategoryChannelModel>;
|
||||
|
||||
/** categoryChannelsBySortOrder : Retrieves assocated category channels sorted by sort_order */
|
||||
@lazy categoryChannelsBySortOrder = this.categoryChannels.collection.query(Q.sortBy('sort_order', Q.asc));
|
||||
@lazy categoryChannelsBySortOrder = this.categoryChannels.collection.query(
|
||||
Q.where('category_id', this.id),
|
||||
Q.sortBy('sort_order', Q.asc),
|
||||
);
|
||||
|
||||
/** channels : Retrieves all the channels that are part of this category */
|
||||
@lazy channels = this.collections.
|
||||
get<ChannelModel>(CHANNEL).
|
||||
query(
|
||||
Q.experimentalJoinTables([CHANNEL, CATEGORY_CHANNEL]),
|
||||
Q.on(CATEGORY_CHANNEL,
|
||||
Q.and(
|
||||
Q.on(CHANNEL, Q.where('delete_at', Q.eq(0))),
|
||||
Q.where('category_id', this.id),
|
||||
),
|
||||
),
|
||||
Q.on(CATEGORY_CHANNEL, 'category_id', this.id),
|
||||
Q.where('delete_at', Q.eq(0)),
|
||||
Q.sortBy('display_name'),
|
||||
);
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import {MM_TABLES} from '@constants/database';
|
||||
import type CategoryModel from '@typings/database/models/servers/category';
|
||||
import type CategoryChannelInterface from '@typings/database/models/servers/category_channel';
|
||||
import type ChannelModel from '@typings/database/models/servers/channel';
|
||||
import type MyChannelModel from '@typings/database/models/servers/my_channel';
|
||||
|
||||
const {CATEGORY_CHANNEL, CATEGORY, MY_CHANNEL, CHANNEL} = MM_TABLES.SERVER;
|
||||
|
||||
@@ -50,5 +51,5 @@ export default class CategoryChannelModel extends Model implements CategoryChann
|
||||
@immutableRelation(CHANNEL, 'channel_id') channel!: Relation<ChannelModel>;
|
||||
|
||||
/** myChannel : The related myChannel */
|
||||
@immutableRelation(MY_CHANNEL, 'channel_id') myChannel!: Relation<ChannelModel>;
|
||||
@immutableRelation(MY_CHANNEL, 'channel_id') myChannel!: Relation<MyChannelModel>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user