forked from chainapsis/keplr-wallet
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: jaswinder.khartri@fetch.ai <jaswinder.khartri@fetch.ai> Co-authored-by: jas2212 <93518923+jas2212@users.noreply.github.com>
- Loading branch information
1 parent
2cafffe
commit 9c78b41
Showing
137 changed files
with
7,399 additions
and
944 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
// Params Type Definitions | ||
|
||
export interface NewGroupDetails { | ||
isEditGroup: boolean; | ||
group: GroupDetails; | ||
} | ||
export interface GroupDetails { | ||
contents: string; | ||
description: string; | ||
groupId: string; | ||
members: GroupMembers[]; | ||
name: string; | ||
onlyAdminMessages: boolean; | ||
} | ||
|
||
export interface GroupMembers { | ||
address: string; | ||
pubKey: string; | ||
encryptedSymmetricKey: string; | ||
isAdmin: boolean; | ||
} | ||
|
||
export interface GroupMessagePayload { | ||
message: string; | ||
type: string; | ||
} | ||
|
||
export interface PublicKeyDetails { | ||
address: string; | ||
channelId: string; | ||
privacySetting: string; | ||
publicKey: string; | ||
} | ||
|
||
export interface NewMessageUpdate { | ||
type: string; | ||
message: Message; | ||
} | ||
|
||
// Graphql Type Definitions | ||
export interface Message { | ||
id: string; | ||
sender: string; | ||
target: string; | ||
contents: string; | ||
groupId: string; | ||
expiryTimestamp: string; | ||
commitTimestamp: string; | ||
} | ||
|
||
export interface GroupAddress { | ||
address: string; | ||
pubKey: string; | ||
lastSeenTimestamp: string; | ||
groupLastSeenTimestamp: string; | ||
encryptedSymmetricKey: string; | ||
isAdmin: boolean; | ||
removedAt: Date; | ||
} | ||
|
||
export interface Group { | ||
id: string; // groupID | ||
name: string; // contactAddress | ||
isDm: boolean; | ||
addresses: GroupAddress[]; | ||
lastMessageContents: string; | ||
lastMessageSender: string; | ||
lastMessageTimestamp: string; | ||
lastSeenTimestamp: string; | ||
description?: string; | ||
createdAt: string; | ||
removedAt: Date; | ||
} | ||
|
||
export interface Pagination { | ||
page: number; | ||
pageCount: number; | ||
total: number; | ||
lastPage: number; | ||
} | ||
|
||
//Redux Selectors Type Definitions | ||
export interface Messages { | ||
[key: string]: Message; | ||
} | ||
|
||
export interface Chat { | ||
contactAddress: string; | ||
messages: Messages; | ||
pubKey?: string; | ||
pagination: Pagination; | ||
} | ||
|
||
//key is group ID | ||
export interface Chats { | ||
[key: string]: Chat; | ||
} | ||
|
||
export interface BlockedAddressState { | ||
[key: string]: boolean; | ||
} | ||
|
||
export interface Groups { | ||
[contactAddress: string]: Group; | ||
} | ||
|
||
export interface NameAddress { | ||
[key: string]: string; | ||
} | ||
|
||
export enum GroupChatOptions { | ||
groupInfo, | ||
muteGroup, | ||
leaveGroup, | ||
deleteGroup, | ||
chatSettings, | ||
} | ||
|
||
export enum GroupChatMemberOptions { | ||
addToAddressBook, | ||
viewInAddressBook, | ||
messageMember, | ||
removeMember, | ||
removeAdminStatus, | ||
makeAdminStatus, | ||
dissmisPopup, | ||
} | ||
|
||
export enum CommonPopupOptions { | ||
cancel, | ||
ok, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
packages/extension/src/components/chat-actions-dropdown/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import amplitude from "amplitude-js"; | ||
import React from "react"; | ||
import { useHistory } from "react-router"; | ||
import style from "./style.module.scss"; | ||
|
||
export const ChatActionsDropdown = ({ | ||
added, | ||
blocked, | ||
showDropdown, | ||
handleClick, | ||
}: { | ||
added: boolean; | ||
blocked: boolean; | ||
showDropdown: boolean; | ||
handleClick: (data: string) => void; | ||
}) => { | ||
return ( | ||
<> | ||
{showDropdown && ( | ||
<div className={style.dropdown}> | ||
{added ? <ViewContactOption /> : <AddContactOption />} | ||
{blocked ? ( | ||
<UnblockOption handleClick={handleClick} /> | ||
) : ( | ||
<BlockOption handleClick={handleClick} /> | ||
)} | ||
{/* <div onClick={() => handleClick("delete")}>Delete chat</div> */} | ||
</div> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
const ViewContactOption = () => { | ||
const history = useHistory(); | ||
return ( | ||
<div | ||
onClick={() => { | ||
amplitude.getInstance().logEvent("Address book viewed", {}); | ||
history.push("/setting/address-book"); | ||
}} | ||
> | ||
View in address book | ||
</div> | ||
); | ||
}; | ||
|
||
const AddContactOption = () => { | ||
const history = useHistory(); | ||
const userName = history.location.pathname.split("/")[2]; | ||
return ( | ||
<div | ||
onClick={() => { | ||
amplitude.getInstance().logEvent("Add to address click", {}); | ||
history.push({ | ||
pathname: "/setting/address-book", | ||
state: { | ||
openModal: true, | ||
addressInputValue: userName, | ||
}, | ||
}); | ||
}} | ||
> | ||
Add to address book | ||
</div> | ||
); | ||
}; | ||
|
||
const BlockOption = ({ | ||
handleClick, | ||
}: { | ||
handleClick: (data: string) => void; | ||
}) => { | ||
return ( | ||
<div | ||
onClick={() => { | ||
amplitude.getInstance().logEvent("Block click", {}); | ||
handleClick("block"); | ||
}} | ||
> | ||
Block contact | ||
</div> | ||
); | ||
}; | ||
|
||
const UnblockOption = ({ | ||
handleClick, | ||
}: { | ||
handleClick: (data: string) => void; | ||
}) => { | ||
return ( | ||
<div | ||
onClick={() => { | ||
amplitude.getInstance().logEvent("Unblock click", {}); | ||
handleClick("unblock"); | ||
}} | ||
> | ||
Unblock contact | ||
</div> | ||
); | ||
}; |
File renamed without changes.
50 changes: 50 additions & 0 deletions
50
packages/extension/src/components/chat-actions-popup/alert-popup.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from "react"; | ||
import style from "./style.module.scss"; | ||
import { CommonPopupOptions } from "@chatTypes"; | ||
export const AlertPopup = ({ | ||
heading, | ||
description, | ||
firstButtonTitle, | ||
secondButtonTitle, | ||
processing, | ||
onClick, | ||
}: { | ||
setConfirmAction: React.Dispatch<React.SetStateAction<boolean>>; | ||
heading: string; | ||
description: string; | ||
firstButtonTitle: string; | ||
secondButtonTitle: string; | ||
processing?: boolean; | ||
onClick: (option: CommonPopupOptions) => void; | ||
}) => { | ||
return ( | ||
<> | ||
<div className={style.overlay} /> | ||
<div className={style.popup}> | ||
<h4>{heading}</h4> | ||
<section> | ||
<p style={{ whiteSpace: "pre-wrap" }} className={style.textContainer}> | ||
{description} | ||
</p> | ||
</section> | ||
<div className={style.buttonContainer}> | ||
<button | ||
type="button" | ||
disabled={processing} | ||
onClick={() => onClick(CommonPopupOptions.cancel)} | ||
> | ||
{firstButtonTitle} | ||
</button> | ||
<button | ||
type="button" | ||
className={style.btn} | ||
disabled={processing} | ||
onClick={() => onClick(CommonPopupOptions.ok)} | ||
> | ||
{secondButtonTitle} | ||
</button> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; |
2 changes: 1 addition & 1 deletion
2
...rc/pages/chatSection/block-user-popup.tsx → ...s/chat-actions-popup/block-user-popup.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.