From ecd80fcd4f51280cf6581d985f9cbade0042dfeb Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Wed, 13 Oct 2021 14:28:09 -0300 Subject: [PATCH] Add channel model property for shared channels (#5749) --- app/database/models/server/channel.ts | 3 +++ .../operator/server_data_operator/transformers/channel.test.ts | 2 +- .../operator/server_data_operator/transformers/channel.ts | 1 + app/database/schema/server/table_schemas/channel.ts | 1 + app/database/schema/server/test.ts | 2 ++ app/screens/channel/channel_nav_bar/channel_title/index.tsx | 2 +- types/api/channels.d.ts | 2 +- types/database/models/servers/channel.d.ts | 3 +++ 8 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/database/models/server/channel.ts b/app/database/models/server/channel.ts index 1db35193aa..a81de37e60 100644 --- a/app/database/models/server/channel.ts +++ b/app/database/models/server/channel.ts @@ -91,6 +91,9 @@ export default class ChannelModel extends Model { /** name : The name of the channel (e.g town-square) */ @field('name') name!: string; + /** shared: determines if it is a shared channel with another organization */ + @field('shared') shared!: boolean; + /** team_id : The team to which this channel belongs. It can be empty for direct/group message. */ @field('team_id') teamId!: string; diff --git a/app/database/operator/server_data_operator/transformers/channel.test.ts b/app/database/operator/server_data_operator/transformers/channel.test.ts index 282f6b7200..0c8a4e663c 100644 --- a/app/database/operator/server_data_operator/transformers/channel.test.ts +++ b/app/database/operator/server_data_operator/transformers/channel.test.ts @@ -39,7 +39,7 @@ describe('*** CHANNEL Prepare Records Test ***', () => { creator_id: '', scheme_id: null, group_constrained: null, - shared: null, + shared: false, }, }, }); diff --git a/app/database/operator/server_data_operator/transformers/channel.ts b/app/database/operator/server_data_operator/transformers/channel.ts index 8b059943bf..ed1af536ac 100644 --- a/app/database/operator/server_data_operator/transformers/channel.ts +++ b/app/database/operator/server_data_operator/transformers/channel.ts @@ -39,6 +39,7 @@ export const transformChannelRecord = ({action, database, value}: TransformerArg channel.displayName = raw.display_name; channel.isGroupConstrained = Boolean(raw.group_constrained); channel.name = raw.name; + channel.shared = Boolean(raw.shared); channel.teamId = raw.team_id; channel.type = raw.type; }; diff --git a/app/database/schema/server/table_schemas/channel.ts b/app/database/schema/server/table_schemas/channel.ts index a12266c04c..39e1cdf425 100644 --- a/app/database/schema/server/table_schemas/channel.ts +++ b/app/database/schema/server/table_schemas/channel.ts @@ -16,6 +16,7 @@ export default tableSchema({ {name: 'display_name', type: 'string'}, {name: 'is_group_constrained', type: 'boolean'}, {name: 'name', type: 'string', isIndexed: true}, + {name: 'shared', type: 'boolean'}, {name: 'team_id', type: 'string', isIndexed: true}, {name: 'type', type: 'string'}, {name: 'update_at', type: 'number'}, diff --git a/app/database/schema/server/test.ts b/app/database/schema/server/test.ts index 84e37705cc..9d0dd67010 100644 --- a/app/database/schema/server/test.ts +++ b/app/database/schema/server/test.ts @@ -71,6 +71,7 @@ describe('*** Test schema for SERVER database ***', () => { type: 'boolean', }, name: {name: 'name', type: 'string', isIndexed: true}, + shared: {name: 'shared', type: 'boolean'}, team_id: {name: 'team_id', type: 'string', isIndexed: true}, type: {name: 'type', type: 'string'}, update_at: {name: 'update_at', type: 'number'}, @@ -83,6 +84,7 @@ describe('*** Test schema for SERVER database ***', () => { {name: 'display_name', type: 'string'}, {name: 'is_group_constrained', type: 'boolean'}, {name: 'name', type: 'string', isIndexed: true}, + {name: 'shared', type: 'boolean'}, {name: 'team_id', type: 'string', isIndexed: true}, {name: 'type', type: 'string'}, {name: 'update_at', type: 'number'}, diff --git a/app/screens/channel/channel_nav_bar/channel_title/index.tsx b/app/screens/channel/channel_nav_bar/channel_title/index.tsx index 4e0fe51127..6224b50668 100644 --- a/app/screens/channel/channel_nav_bar/channel_title/index.tsx +++ b/app/screens/channel/channel_nav_bar/channel_title/index.tsx @@ -56,7 +56,7 @@ const ChannelTitle = ({ const channelType = channel.type; const isArchived = channel.deleteAt !== 0; const isChannelMuted = channelSettings.notifyProps?.mark_unread === 'mention'; - const isChannelShared = false; // todo: Read this value from ChannelModel when implemented + const isChannelShared = channel.shared; const hasGuests = channelInfo.guestCount > 0; const teammateRoles = teammate?.roles ?? ''; const isGuest = channelType === General.DM_CHANNEL && isTeammateGuest(teammateRoles); diff --git a/types/api/channels.d.ts b/types/api/channels.d.ts index 5ea8c1ce18..b5999ac61d 100644 --- a/types/api/channels.d.ts +++ b/types/api/channels.d.ts @@ -34,7 +34,7 @@ type Channel = { status?: string; fake?: boolean; group_constrained: boolean|null; - shared: boolean|null; + shared: boolean; }; type ChannelWithTeamData = Channel & { team_display_name: string; diff --git a/types/database/models/servers/channel.d.ts b/types/database/models/servers/channel.d.ts index 0f075d1af7..8396b0f8b7 100644 --- a/types/database/models/servers/channel.d.ts +++ b/types/database/models/servers/channel.d.ts @@ -35,6 +35,9 @@ export default class ChannelModel extends Model { /** name : The name of the channel (e.g town-square) */ name: string; + /** shared: determines if it is a shared channel with another organization */ + shared: boolean; + /** team_id : The team to which this channel belongs. It can be empty for direct/group message. */ teamId: string;