diff --git a/apps/home/migrations/0018_subchannel_channel_name.py b/apps/home/migrations/0018_subchannel_channel_name.py new file mode 100644 index 0000000..9304dc1 --- /dev/null +++ b/apps/home/migrations/0018_subchannel_channel_name.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.4 on 2024-07-20 18:14 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0017_trackedcontent_message_id'), + ] + + operations = [ + migrations.AddField( + model_name='subchannel', + name='channel_name', + field=models.CharField(default='placeholder-channel-name', help_text='Name of the represented Channel.', max_length=256, verbose_name='channel name'), + preserve_default=False, + ), + ] diff --git a/apps/home/models.py b/apps/home/models.py index e1b065e..4ca2f96 100644 --- a/apps/home/models.py +++ b/apps/home/models.py @@ -94,6 +94,12 @@ class SubChannel(models.Model): help_text=_("Discord snowflake ID for the represented Channel.") ) + channel_name = models.CharField( + verbose_name=_("channel name"), + max_length=256, + help_text=_("Name of the represented Channel.") + ) + subscription = models.ForeignKey( to="home.Subscription", on_delete=models.CASCADE, diff --git a/apps/static/js/home/subscriptions.js b/apps/static/js/home/subscriptions.js index 46da2ae..5d65515 100644 --- a/apps/static/js/home/subscriptions.js +++ b/apps/static/js/home/subscriptions.js @@ -249,7 +249,7 @@ $("#subForm").on("submit", async function(event) { url = $("#subUrl").val(); guildId = getCurrentlyActiveServer().guild_id; extraNotes = $("#subExtraNotes").val(); - subChannels = $("#subChannels option:selected").toArray().map(channel => channel.value); + subChannels = Object.fromEntries($("#subChannels option:selected").toArray().map(channel => [channel.value, $(channel).data("name")])); subFilters = $("#subFilters option:selected").toArray().map(filter => parseInt(filter.value)); subMutators = { title: $("#subTitleMutators option:selected").toArray().map(mutator => parseInt(mutator.value)), @@ -267,6 +267,7 @@ $("#subForm").on("submit", async function(event) { return } + // continue here, channel name await deleteSubChannels(subPrimaryKey); subChannels.forEach(async channelId => { await saveSubChannel(channelId, subPrimaryKey); @@ -511,7 +512,7 @@ async function loadChannelOptions(guildId) { if (channel.type !== 0) return; - let channelObj = {text: `#${channel.name}`, value: channel.id} + let channelObj = {text: `#${channel.name}`, value: channel.id, "data-name": channel.name} $("#subChannels").append($("