User avatar
pathetic piss kitten @kitten@elizabeth.cat
1y
rambling about software and my fediverse client okay, so, let's discuss how to build this

a fediverse post has two sets of emojis associated to them: the emojis that are in the content of the post, and the ones in the reactions to the post

in my app's database, I have two main tables for that, PostEntity, and EmojiEntity. it's an N:M relationship, so I have an auxiliary table called PostEmojiCrossRef with just two columns, postId, and emojiId

now, notice that even though we mentioned
two sets of emojis, they're all stored together, with no distinction.

this is causing me a problem for a very simple reason: in the post's content, an emoji is only identified by its shortcode (like
​:foo:​). but in the reactions, it's identified by a combination of shortcode@instance, since we could have two different reactions from different instances with the same shortcode for different emojis

this is an issue because rn when loading them, all the emojis are piled into a map with the structure shortcode -> emojiData. so when I'm processing the post text, it's easy to navigate the map by just looking for the shortcode I need at that moment as the key. but now that I'm displaying the reactions, I need to look for shortcode@instance, which obviously isn't in the map

now, I have two solutions:

the easy one, make that map always use shortcode@instance as keys, and when processing posts' text, always append the post author's instance to the shortcode in the text (since it'll never be any other instance)

that'd be pretty simple, but I'm also thinking that it might be better to just have two maps, one for the post emojis, still using the shortcodes, and another one for the reactions, using shortcode@instance as keys
❤️1
2
0
2
1
User avatar
nightscy @nightscy@kinkycats.org
1y
rambling about software and my fediverse client @kitten Yeah I'd say do the former. Because that's ultimately what it is: The emojis in the post are shortcode@instance, they're just not written that way by the person creating the post.
2
0
1
0
User avatar
pathetic piss kitten @kitten@elizabeth.cat
1y
rambling about software and my fediverse client @nightscy yeah, that's true...
0
0
1
0