Skip to content

Commit

Permalink
perf(radio): reduce message updates while re-scanning
Browse files Browse the repository at this point in the history
  • Loading branch information
vittee committed May 14, 2024
1 parent 559e10b commit e340885
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/radio/src/discord/command/commands/rescan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CommandInteraction, blockQuote, inlineCode, unorderedList } from "disco
import { CommandDescriptor, InteractionHandlerFactory, OptionType, SubCommandLikeOption } from "../type";
import { deny, guildStationGuard, joinStrings, reply } from "../utils";
import { LibraryRescanStats, MusicTrackCollection, Station } from "@seamless-medley/core";
import { once } from "lodash";

const declaration: SubCommandLikeOption = {
type: OptionType.SubCommand,
Expand All @@ -23,12 +24,12 @@ const createCommandHandler: InteractionHandlerFactory<CommandInteraction> = (aut

const { station } = guildStationGuard(automaton, interaction);

const stats = await station.rescan(true, (col) => {
const stats = await station.rescan(true, once(() => {
reply(interaction, {
ephemeral: true,
content: `Re-scanning: ${col.extra.description}`
content: `Re-scanning...`
});
})
}));

type Stat = Omit<LibraryRescanStats<Station>, 'collection'>;

Expand Down

0 comments on commit e340885

Please sign in to comment.