Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
TLV Max Message
let record = {
7629169: {
podcast:
$playingPodcast.title.length < 101
? $playingPodcast.title
: $playingPodcast.title.substring(0, 100) + '...',
feedID: $playingPodcast.id,
episode:
$playingEpisode.title.length < 101
? $playingEpisode.title
: $playingEpisode.title.substring(0, 100) + '...',
action: 'boost',
ts: Math.floor($playerTime),
boost_link: createBoostLink(Math.floor($playerTime)),
app_name: 'CurioCaster',
url: $playingPodcast.url,
},
};
let baseLength = new Blob([JSON.stringify(record, null, 0)]).size;
let longestName = '';
let longestNameLength = 0;
let recordNameLength = 0;
destinations = $playingPodcast.value.destinations;
for (let dest of destinations) {
if (dest?.name?.length > longestNameLength) {
longestNameLength = dest?.name?.length;
longestName = dest?.name;
}
}
recordNameLength = new Blob([
JSON.stringify({ name: longestName }, null, 0),
]).size;
let tipLength = new Blob([
JSON.stringify(
{ value_msat: satValue * 1000, value_msat_total: satValue * 1000 },
null,
0
),
]).size;
let senderLength = new Blob([JSON.stringify({ sender: sender }, null, 0)])
.size;
let maxTextLength =
Math.floor(
(1200 - (baseLength + tipLength + recordNameLength + senderLength)) / 100
) * 100;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment