[FIX] Update the number of members from a room
This commit is contained in:
parent
58391964cb
commit
011c99d406
|
@ -102,6 +102,7 @@ export interface ISubscription {
|
||||||
onHold?: boolean;
|
onHold?: boolean;
|
||||||
source?: IOmnichannelSource;
|
source?: IOmnichannelSource;
|
||||||
hideMentionStatus?: boolean;
|
hideMentionStatus?: boolean;
|
||||||
|
usersCount?: number;
|
||||||
// https://nozbe.github.io/WatermelonDB/Relation.html#relation-api
|
// https://nozbe.github.io/WatermelonDB/Relation.html#relation-api
|
||||||
messages: RelationModified<TMessageModel>;
|
messages: RelationModified<TMessageModel>;
|
||||||
threads: RelationModified<TThreadModel>;
|
threads: RelationModified<TThreadModel>;
|
||||||
|
|
|
@ -137,5 +137,7 @@ export default class Subscription extends Model {
|
||||||
|
|
||||||
@field('on_hold') onHold;
|
@field('on_hold') onHold;
|
||||||
|
|
||||||
|
@field('users_count') usersCount;
|
||||||
|
|
||||||
@json('source', sanitizer) source;
|
@json('source', sanitizer) source;
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,6 +257,15 @@ export default schemaMigrations({
|
||||||
columns: [{ name: 'e2e_suggested_key', type: 'string', isOptional: true }]
|
columns: [{ name: 'e2e_suggested_key', type: 'string', isOptional: true }]
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
toVersion: 21,
|
||||||
|
steps: [
|
||||||
|
addColumns({
|
||||||
|
table: 'subscriptions',
|
||||||
|
columns: [{ name: 'users_count', type: 'string', isOptional: true }]
|
||||||
|
})
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { appSchema, tableSchema } from '@nozbe/watermelondb';
|
import { appSchema, tableSchema } from '@nozbe/watermelondb';
|
||||||
|
|
||||||
export default appSchema({
|
export default appSchema({
|
||||||
version: 20,
|
version: 21,
|
||||||
tables: [
|
tables: [
|
||||||
tableSchema({
|
tableSchema({
|
||||||
name: 'subscriptions',
|
name: 'subscriptions',
|
||||||
|
@ -63,7 +63,8 @@ export default appSchema({
|
||||||
{ name: 'team_main', type: 'boolean', isOptional: true }, // Use `Q.notEq(true)` to get false or null
|
{ name: 'team_main', type: 'boolean', isOptional: true }, // Use `Q.notEq(true)` to get false or null
|
||||||
{ name: 'on_hold', type: 'boolean', isOptional: true },
|
{ name: 'on_hold', type: 'boolean', isOptional: true },
|
||||||
{ name: 'source', type: 'string', isOptional: true },
|
{ name: 'source', type: 'string', isOptional: true },
|
||||||
{ name: 'hide_mention_status', type: 'boolean', isOptional: true }
|
{ name: 'hide_mention_status', type: 'boolean', isOptional: true },
|
||||||
|
{ name: 'users_count', type: 'number', isOptional: true }
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
tableSchema({
|
tableSchema({
|
||||||
|
|
|
@ -85,6 +85,9 @@ export const merge = (
|
||||||
if (room && 'source' in room) {
|
if (room && 'source' in room) {
|
||||||
mergedSubscription.source = room?.source;
|
mergedSubscription.source = room?.source;
|
||||||
}
|
}
|
||||||
|
if (room && 'usersCount' in room) {
|
||||||
|
mergedSubscription.usersCount = room.usersCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mergedSubscription.name) {
|
if (!mergedSubscription.name) {
|
||||||
|
|
|
@ -85,7 +85,7 @@ interface IRoomActionsViewProps extends IActionSheetProvider, IBaseScreen<ChatsS
|
||||||
|
|
||||||
interface IRoomActionsViewState {
|
interface IRoomActionsViewState {
|
||||||
room: TSubscriptionModel;
|
room: TSubscriptionModel;
|
||||||
membersCount: number;
|
membersCount?: number;
|
||||||
member: Partial<IUser>;
|
member: Partial<IUser>;
|
||||||
joined: boolean;
|
joined: boolean;
|
||||||
canViewMembers: boolean;
|
canViewMembers: boolean;
|
||||||
|
@ -152,7 +152,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
|
||||||
this.roomObservable = room.observe();
|
this.roomObservable = room.observe();
|
||||||
this.subscription = this.roomObservable.subscribe(changes => {
|
this.subscription = this.roomObservable.subscribe(changes => {
|
||||||
if (this.mounted) {
|
if (this.mounted) {
|
||||||
this.setState({ room: changes });
|
this.setState({ room: changes, membersCount: changes.usersCount });
|
||||||
} else {
|
} else {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.state.room = changes;
|
this.state.room = changes;
|
||||||
|
@ -1050,7 +1050,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
|
||||||
<>
|
<>
|
||||||
<List.Item
|
<List.Item
|
||||||
title='Members'
|
title='Members'
|
||||||
subtitle={membersCount > 0 ? `${membersCount} ${I18n.t('members')}` : undefined}
|
subtitle={membersCount && membersCount > 0 ? `${membersCount} ${I18n.t('members')}` : undefined}
|
||||||
onPress={() => this.onPressTouchable({ route: 'RoomMembersView', params: { rid, room, joined: this.joined } })}
|
onPress={() => this.onPressTouchable({ route: 'RoomMembersView', params: { rid, room, joined: this.joined } })}
|
||||||
testID='room-actions-members'
|
testID='room-actions-members'
|
||||||
left={() => <List.Icon name='team' />}
|
left={() => <List.Icon name='team' />}
|
||||||
|
|
Loading…
Reference in New Issue