snow-stamp icon indicating copy to clipboard operation
snow-stamp copied to clipboard

Parse and display multiple snowflakes

Open p0lygun opened this issue 2 years ago • 8 comments

When you hold shift on a message it opens a new context menu that lets one quickly copy the id but the return value is different image returns 423250272316293120-938804470408699954 (channel_id-message-id) instead of just 938803791346679809 (message-id) currently using this will yield image

p0lygun avatar Feb 04 '22 09:02 p0lygun

Interesting, I didn't know about this. What would you expect the result to be?

vegeta897 avatar Feb 04 '22 09:02 vegeta897

adding something like

snowflake = snowflake.split("-").at(-1)

before https://github.com/vegeta897/snow-stamp/blob/main/src/convert.js#L13 should do the trick as we dont care for the left hand side part after the split

p0lygun avatar Feb 04 '22 09:02 p0lygun

I'm sort of wondering if it would be better to strip it out of the input box on paste before it reaches validation, because syncing the URL with that two-part snowflake might get kind of messy.

vegeta897 avatar Feb 04 '22 09:02 vegeta897

yh that is also a good approach, i was just looking at convert js so didnt think of the lol

p0lygun avatar Feb 04 '22 09:02 p0lygun

The only part I don't like about automatically stripping it out is that it's kind of bad UX if the user doesn't understand what's happening when they see something different than what they pasted.

I could use this opportunity to develop support for pasting in multiple snowflakes. If it detects multiple, however delimited, it could convert the input into a multi-line and show a snowflake on each line, and let you select which one to show the conversion for (with one selected automatically by default, to avoid requiring an extra click in this use-case). The URL would be the selected snowflake.

vegeta897 avatar Feb 04 '22 09:02 vegeta897

i would recommend against it, as take this 423250272316293120-938769477812764682 for an example both of them are valid snowflakes but only one of them is a message timestamp, i believe if we try to convert the first one it should give us when the channel was created, lemme confirm

p0lygun avatar Feb 04 '22 09:02 p0lygun

If that is the channel ID then yes, it would be when the channel is created.

Snow-Stamp's job is to convert snowflakes to timestamps, so I want to keep the input>output results as unsurprising as possible. Automatically ignoring the first snowflake in a pair like that just because the user likely copied it from a message feels like bad design to me.

By automatically splitting up the input into the two snowflakes, the user can understand what happened and get the result they were looking for, it seems like win/win to me.

vegeta897 avatar Feb 04 '22 09:02 vegeta897

This multi-input idea would also be a good start for implementing #155

Now I have to decide whether I want to do all this before or after a typescript/sveltekit rewrite.

vegeta897 avatar Feb 04 '22 10:02 vegeta897