Skip to content

Commit

Permalink
Merge pull request #13 from hecom-rn/hanhu
Browse files Browse the repository at this point in the history
  • Loading branch information
summer88123 authored Dec 29, 2020
2 parents f605372 + d2935c0 commit afffa24
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 1 deletion.
3 changes: 2 additions & 1 deletion language/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@
"IMSettingTransferOwnerAction": "转交",
"IMToastError": "{{action}}失败",
"IMToastMessageNotSupport": "当前版本暂不支持该消息",
"IMToastSuccess": "{{action}}成功"
"IMToastSuccess": "{{action}}成功",
"IMSettingGroupDataInfo": "资料"
}
63 changes: 63 additions & 0 deletions plugin/setting/GroupData.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import React from 'react';
import { View } from 'react-native';
import Toast from 'react-native-root-toast';
import i18n from 'i18n-js';
import { Typings, Delegate } from '../../standard';

export const name = 'IMSettingGroupDataInfo';

export function getUi(props: Typings.Action.Setting.Params): Typings.Action.Setting.Result {
const {key, imId, chatType} = props;
const isGroup = chatType === Typings.Conversation.ChatType.Group;
if (!isGroup) {
return null;
}
const groupName = Delegate.model.Group.getName(imId, false);
const groupOwner = Delegate.model.Group.getOwner(imId);
const isOwner = groupOwner === Delegate.user.getMine().userId;
return (
<GroupDataInfoCell
key={key}
isOwner={isOwner}
groupName={groupName}
imId={imId}
/>
);
}

export interface Props {
isOwner: boolean;
groupName: string | void;
imId: string;
}

export interface State {
}

export class GroupDataInfoCell extends React.PureComponent<Props,State> {
state: State = {
};

render() {
return (
<View>
<Delegate.component.SettingItem
type={Typings.Component.SettingItemType.Text}
title={i18n.t('IMSettingGroupDataInfo')}
data={""}
onPressLine={this._clickLine.bind(this)}
/>
</View>
);
}

protected _clickLine() {
const {imId} = this.props;
Delegate.model.Group.showGroupDataRecord(imId)
.catch(() => {
Toast.show(i18n.t('IMToastError', {
action: i18n.t('IMSettingGroupDataInfo'),
}));
});
}
}
4 changes: 4 additions & 0 deletions plugin/setting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as GroupAvatar from './GroupAvatar';
import * as GroupMemberName from './GroupMemberName';
import * as GroupName from './GroupName';
import * as GroupAnnouncement from './GroupAnnouncement';
import * as GroupData from './GroupData';
import * as LeaveGroup from './LeaveGroup';
import * as Top from './Top';
import * as TransferOwner from './TransferOwner';
Expand All @@ -23,6 +24,7 @@ export function setup() {
[AllowInvite.name, AllowInvite.getUi],
[AvatarList.name, AvatarList.getUi],
[Avoid.name, Avoid.getUi],
[GroupData.name,GroupData.getUi],
[GroupAvatar.name, GroupAvatar.getUi],
[GroupMemberName.name, GroupMemberName.getUi],
[GroupName.name, GroupName.getUi],
Expand All @@ -36,6 +38,7 @@ export function setup() {
});
Delegate.page[PageKeys.ChatSetting].defaultProps.sections = [
[AvatarList.name, AllMembers.name],
[GroupData.name],
[GroupName.name, GroupAvatar.name, GroupAnnouncement.name, AllowInvite.name, Top.name, Avoid.name, GroupMemberName.name]
];
Delegate.page[PageKeys.ChatSetting].defaultProps.buttons = [
Expand All @@ -49,6 +52,7 @@ export {
AllowInvite,
AvatarList,
Avoid,
GroupData,
GroupAvatar,
GroupName,
GroupAnnouncement,
Expand Down
Binary file added standard/component/image/showMore@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions standard/model/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ export async function changeName(groupId: string, newName: string): Promise<stri
return changeGroupInfo(groupId, {name: newName}, newName);
}

export async function showGroupDataRecord(imId:string) {
await delegate.im.group.showGroupDataRecord(imId)
}

export async function changeAnnouncement(groupId: string, newAnnouncement: string): Promise<string> {
await delegate.im.group.changeAnnouncement(groupId, newAnnouncement);
return changeGroupInfo(groupId, {announcement: newAnnouncement}, newAnnouncement);
Expand Down
2 changes: 2 additions & 0 deletions standard/typings/Delegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export interface GroupModelPart {
changeAvatar: (groupId: string, newAvatarUrl: string) => Promise<string>;
changeAllowInvites: (groupId: string, allowInvites: boolean) => Promise<boolean>;
changeOwner: (groupId: string, newOwnerId: string) => Promise<{ owner: string; members: string[] }>;
showGroupDataRecord:(imId:String) => Promise<void>;
}

export interface MessageModelPart {
Expand Down Expand Up @@ -153,6 +154,7 @@ export interface GroupApiPart {
changeAvatar: (groupId: string, newAvatarUrl: string) => Promise<void>;
changeAllowInvites: (groupId: string, newAllowInvites: boolean) => Promise<void>;
changeOwner: (groupId: string, newOwnerId: string) => Promise<void>;
showGroupDataRecord:(imId:String) => Promise<void>;
}

export interface ApiPart {
Expand Down

0 comments on commit afffa24

Please sign in to comment.