chylex / Discord-History-Tracker

Desktop app & browser script that saves Discord chat history into a file, and an offline viewer that displays the file.
https://dht.chylex.com
MIT License
447 stars 80 forks source link

`channelId` argument is always `undefined`, but also unnecessary? #235

Closed will-ca closed 7 months ago

will-ca commented 7 months ago

TL;DR: The channelId argument for STATE.addDiscordMessages in the Desktop version is really just dead code/never used, with channel IDs instead being read from the .channel_id properties in the message array:

https://github.com/chylex/Discord-History-Tracker/blob/d35280a6a6fed6accf951925d1927fc854204399/app/Resources/Tracker/scripts/state.js#L176-L180

https://github.com/chylex/Discord-History-Tracker/blob/d35280a6a6fed6accf951925d1927fc854204399/app/Resources/Tracker/scripts/state.js#L222-L229

So this argument can probably just be removed.


But also, I think it's always passed an `undefined` property as well. (Click to expand details.) Is `info.id` the correct value to give `STATE.addDiscordMessages()` at `bootstrap.js:124`? #### Desktop https://github.com/chylex/Discord-History-Tracker/blob/d35280a6a6fed6accf951925d1927fc854204399/app/Resources/Tracker/bootstrap.js#L123-L126 I believe this was probably carried over from the browser version, around `Σ.js:49/83/105`: #### Browser https://github.com/chylex/Discord-History-Tracker/blob/ce87901088d13741d8ec74f17d7f3789a751769a/src/tracker/%CE%A3.js#L103-L106 However, `info` is always assigned from `DISCORD.getSelectedChannel()`. And the object returned by `DISCORD.getSelectedChannel()` has changed for the desktop version: #### Browser https://github.com/chylex/Discord-History-Tracker/blob/ce87901088d13741d8ec74f17d7f3789a751769a/src/tracker/discord.js#L230-L240 #### Desktop https://github.com/chylex/Discord-History-Tracker/blob/d35280a6a6fed6accf951925d1927fc854204399/app/Resources/Tracker/scripts/discord.js#L213-L225 https://github.com/chylex/Discord-History-Tracker/blob/d35280a6a6fed6accf951925d1927fc854204399/app/Resources/Tracker/scripts/discord.js#L235 Therefore I think `info.id` will always be `undefined`, and the correct value should probably be `info.channel.id`, if you do want to use it.
chylex commented 7 months ago

Seems right, thanks.