Make core.get_favorites("local") ignore duplicates (#7926)
authorPaul Ouellette <oue.paul18@gmail.com>
Fri, 8 Nov 2019 21:18:20 +0000 (16:18 -0500)
committerSmallJoker <SmallJoker@users.noreply.github.com>
Fri, 8 Nov 2019 21:18:20 +0000 (22:18 +0100)
src/serverlist.cpp

index 7d3ab4bbb568370934649cad2d6c574875a7234f..18264e933cce2f8f5e0032b1f00d10b9668f7c58 100644 (file)
@@ -155,6 +155,16 @@ std::vector<ServerListSpec> deSerialize(const std::string &liststring)
                        server["address"] = tmp;
                        std::getline(stream, tmp);
                        server["port"] = tmp;
+                       bool unique = true;
+                       for (const ServerListSpec &added : serverlist) {
+                               if (server["name"] == added["name"]
+                                               && server["port"] == added["port"]) {
+                                       unique = false;
+                                       break;
+                               }
+                       }
+                       if (!unique)
+                               continue;
                        std::getline(stream, tmp);
                        server["description"] = tmp;
                        serverlist.push_back(server);