Skip to content

Commit

Permalink
fix: fix max title length (#180)
Browse files Browse the repository at this point in the history
* fix: fix max title length

* fix: show ellipsis for truncated text

* fix: put back commented body
  • Loading branch information
wa0x6e authored Apr 2, 2024
1 parent 81db1d3 commit fe66706
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,9 @@ export async function getSpace(id) {
return null;
}
}

export function truncate(string: string, length: number) {
return string.length > length
? `${string.substring(0, length - 1)}…`
: string;
}
3 changes: 2 additions & 1 deletion src/providers/walletconnectNotify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import snapshot from '@snapshot-labs/snapshot.js';
import { capture } from '@snapshot-labs/snapshot-sentry';
import { timeOutgoingRequest, outgoingMessages } from '../helpers/metrics';
import type { Event } from '../types';
import { truncate } from '../helpers/utils';

const WALLETCONNECT_NOTIFY_SERVER_URL =
process.env.WALLETCONNECT_NOTIFY_SERVER_URL;
Expand Down Expand Up @@ -98,7 +99,7 @@ function formatMessage(event: Event, proposal) {

const url = `${proposal.link}?app=web3inbox`;
return {
title: proposal.title,
title: truncate(proposal.title, 64),
body: notificationBody,
url,
type: notificationType
Expand Down

0 comments on commit fe66706

Please sign in to comment.