Genoa's allies included Hungary and Padua. The King of Hungary, Louis I, had conquered Dalmatia from Venice and by 1379 Hungarian forces threatened Venice itself by land from the north. Paduan forces, under the leadership of Francesco I da Carrara, cut off Venice's communications to the west.  Genoa's allies also included the Patriarch of Aquileia and Leopold III, the Duke of Austria. The danger on land seemed trifling to Venice so long as she could keep the sea open to her trade and press the war against the Genoese in the Levant.  Venice's allies, which included Bernabò Visconti of Milan, gave her little help on this side, although his mercenaries invaded the territory of Genoa. The Milanese troops were indeed  defeated in September 1379 in the Val Bisagno.  Bernabò, whose despotism and taxes had enraged the Milanese, was deposed by his nephew Gian Galeazzo Visconti in 1385. Imprisoned in the castle of Trezzo, he was poisoned in December of that year. Venice had the support of John V Palaiologos, Byzantine Emperor. In 1376, the Genoese helped Andronikos IV  overthrown John V, but in 1379 Venice restored the latter to the throne.
Question: What happened first, the defeat of the Milanese troops or imprisonment of Bernabo?
Answer: defeat of the Milanese troops