added translations for toast messages

This commit is contained in:
2025-01-18 15:24:16 +01:00
parent ea325e23c5
commit 558b7354ca
9 changed files with 54 additions and 57 deletions

View File

@@ -196,7 +196,7 @@ func (f *FTDIFinder) scanPeripherals(ctx context.Context) error {
// The program output is like '0:1:2' where 0 is the location, 1 is the S/N and 2 is the name
peripheralInfo := strings.Split(peripheralString, ":")
log.Debug().Str("file", "FTDIFinder").Str("peripheralName", peripheralInfo[2]).Str("peripheralSN", peripheralInfo[1]).Msg("new FTDI peripheral detected")
log.Trace().Str("file", "FTDIFinder").Str("scannedString", peripheralString).Str("peripheralName", peripheralInfo[2]).Str("peripheralSN", peripheralInfo[1]).Msg("new FTDI peripheral detected")
// Convert the location to an integer
location, err := strconv.Atoi(peripheralInfo[0])
if err != nil {
@@ -208,16 +208,13 @@ func (f *FTDIFinder) scanPeripherals(ctx context.Context) error {
if err != nil {
return fmt.Errorf("unable to create the FTDI peripheral: %v", err)
}
log.Trace().Any("periph", &peripheral).Str("file", "FTDIFinder").Str("peripheralName", peripheralInfo[2]).Msg("has been created")
ftdiPeripherals[peripheralInfo[1]] = peripheral
log.Trace().Str("file", "FTDIFinder").Str("peripheralName", peripheralInfo[2]).Msg("successfully added the FTDI peripheral to the finder")
log.Trace().Any("periph", ftdiPeripherals).Str("file", "FTDIFinder").Str("peripheralName", peripheralInfo[2]).Msg("successfully added the FTDI peripheral to the finder")
}
// Compare with the current peripherals to detect arrivals/removals
removedList, addedList := comparePeripherals(f.peripherals, ftdiPeripherals)
// Emit the events
emitPeripheralsEvents(ctx, removedList, PeripheralRemoval)
log.Info().Str("file", "FTDIFinder").Msg("FTDI remove list emitted to the front")
emitPeripheralsEvents(ctx, addedList, PeripheralArrival)
log.Info().Str("file", "FTDIFinder").Msg("FTDI add list emitted to the front")
// Emit the peripherals changes to the front
emitPeripheralsChanges(ctx, f.peripherals, ftdiPeripherals)
// Store the new peripherals list
f.peripherals = ftdiPeripherals
return nil