From 141d5894bbf705ce2581429ed12987b4f0b2c68d Mon Sep 17 00:00:00 2001 From: NIK Date: Tue, 24 Oct 2023 00:14:04 +0800 Subject: [PATCH] delete previous election edge if it exists --- src/upvote_election/actions.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/upvote_election/actions.cpp b/src/upvote_election/actions.cpp index d70f9f2..15600ff 100644 --- a/src/upvote_election/actions.cpp +++ b/src/upvote_election/actions.cpp @@ -842,6 +842,11 @@ namespace hypha { // delete ongoing election link Edge::get(get_self(), daoId, election.getId(), upvote_common::links::ONGOING_ELECTION).erase(); + // delete previous previous election link + if (auto [exists, edge] = Edge::getIfExists(get_self(), daoId, upvote_common::links::PREVIOUS_ELECTION); exists) { + edge.erase(); + } + // add previous election link Edge(get_self(), get_self(), daoId, election.getId(), upvote_common::links::PREVIOUS_ELECTION);