[Gekidou] various fixes (#6022)

* remove empty roles before fetching

* Fix prepare delete teams, channels and posts so they don't throw

* Fix reaction operator and moved some handlers to their correct file

* include delete categories when teams or channels are deleted

* Remove unused array in fetchRoles

* fix param comment for reactions handler

* don't sync preferences when getting the WS event
This commit is contained in:
Elias Nahum
2022-03-03 12:11:47 -03:00
committed by GitHub
parent e4ed5fe936
commit 162bc6cc3f
22 changed files with 399 additions and 290 deletions

View File

@@ -7,6 +7,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model';
import {MM_TABLES} from '@constants/database';
import type CategoryChannelModel from '@typings/database/models/servers/category_channel';
import type ChannelInfoModel from '@typings/database/models/servers/channel_info';
import type ChannelMembershipModel from '@typings/database/models/servers/channel_membership';
import type DraftModel from '@typings/database/models/servers/draft';
@@ -127,6 +128,9 @@ export default class ChannelModel extends Model {
/** settings: User specific settings/preferences for this channel */
@immutableRelation(MY_CHANNEL_SETTINGS, 'id') settings!: Relation<MyChannelSettingsModel>;
/** categoryChannel : Query returning the membership data for the current user if it belongs to this channel */
@immutableRelation(CATEGORY_CHANNEL, 'channel_id') categoryChannel!: Relation<CategoryChannelModel>;
toApi = (): Channel => {
return {
id: this.id,

View File

@@ -7,6 +7,7 @@ import Model, {Associations} from '@nozbe/watermelondb/Model';
import {MM_TABLES} from '@constants/database';
import type CategoryModel from '@typings/database/models/servers/category';
import type ChannelModel from '@typings/database/models/servers/channel';
import type MyTeamModel from '@typings/database/models/servers/my_team';
import type SlashCommandModel from '@typings/database/models/servers/slash_command';
@@ -15,6 +16,7 @@ import type TeamMembershipModel from '@typings/database/models/servers/team_memb
import type TeamSearchHistoryModel from '@typings/database/models/servers/team_search_history';
const {
CATEGORY,
CHANNEL,
TEAM,
MY_TEAM,
@@ -34,6 +36,9 @@ export default class TeamModel extends Model {
/** associations : Describes every relationship to this table. */
static associations: Associations = {
/** A TEAM has a 1:N relationship with CATEGORY. A TEAM can possess multiple categories */
[CATEGORY]: {type: 'has_many', foreignKey: 'team_id'},
/** A TEAM has a 1:N relationship with CHANNEL. A TEAM can possess multiple channels */
[CHANNEL]: {type: 'has_many', foreignKey: 'team_id'},
@@ -77,6 +82,9 @@ export default class TeamModel extends Model {
/** allowed_domains : List of domains that can join this team */
@field('allowed_domains') allowedDomains!: string;
/** categories : All the categories associated with this team */
@children(CATEGORY) categories!: CategoryModel[];
/** channels : All the channels associated with this team */
@children(CHANNEL) channels!: ChannelModel[];