Skip to content

Commit

Permalink
fix channel schema encode-url-data.ts (#549)
Browse files Browse the repository at this point in the history
* Update encode-url-data.ts

* Create slimy-keys-melt.md

* f

* f
  • Loading branch information
felicio authored Apr 22, 2024
1 parent 2d9dbdd commit 13f7ed5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 27 deletions.
5 changes: 5 additions & 0 deletions .changeset/slimy-keys-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@status-im/js": patch
---

Update encode-url-data.ts
18 changes: 0 additions & 18 deletions packages/status-js/src/utils/encode-url-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,6 @@ describe('Encode URL data', () => {
],
\\"message\\": \\"Required\\"
},
{
\\"code\\": \\"invalid_type\\",
\\"expected\\": \\"string\\",
\\"received\\": \\"undefined\\",
\\"path\\": [
\\"emoji\\"
],
\\"message\\": \\"Required\\"
},
{
\\"code\\": \\"invalid_type\\",
\\"expected\\": \\"string\\",
Expand Down Expand Up @@ -188,15 +179,6 @@ describe('Encode URL data', () => {
],
\\"message\\": \\"Required\\"
},
{
\\"code\\": \\"invalid_type\\",
\\"expected\\": \\"string\\",
\\"received\\": \\"undefined\\",
\\"path\\": [
\\"emoji\\"
],
\\"message\\": \\"Required\\"
},
{
\\"code\\": \\"invalid_type\\",
\\"expected\\": \\"string\\",
Expand Down
12 changes: 3 additions & 9 deletions packages/status-js/src/utils/encode-url-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ export function encodeCommunityURLData(
return encodeURLData(new Community(data).toBinary()) as EncodedURLData
}

// note: PlainMessage<T> type does not ensure returning of only own properties
export function decodeCommunityURLData(data: string): PlainMessage<Community> {
export function decodeCommunityURLData(data: string) {
const deserialized = decodeURLData(data)

const community = Community.fromBinary(deserialized.content).toJson()
Expand All @@ -37,7 +36,7 @@ export function decodeCommunityURLData(data: string): PlainMessage<Community> {
const channelSchema = z.object({
displayName: z.string().max(24).nonempty(),
description: z.string().max(140).nonempty(),
emoji: z.string().emoji(),
emoji: z.string().emoji().optional(),
color: colorSchema,
community: z.object({
displayName: communityDisplayName,
Expand All @@ -51,12 +50,7 @@ export function encodeChannelURLData(
return encodeURLData(new Channel(data).toBinary()) as EncodedURLData
}

export function decodeChannelURLData(data: string): Omit<
PlainMessage<Channel>,
'community'
> & {
community: Pick<PlainMessage<Community>, 'displayName'>
} {
export function decodeChannelURLData(data: string) {
const deserialized = decodeURLData(data)

const channel = Channel.fromBinary(deserialized.content).toJson()
Expand Down

0 comments on commit 13f7ed5

Please sign in to comment.