From 82ac80df972d56c87551eb86044d6dcea8fd0d69 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Sat, 29 Oct 2022 21:16:52 +0100 Subject: [PATCH] Add channel name updates when loading. --- .../me/kavin/piped/utils/ResponseHelper.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/kavin/piped/utils/ResponseHelper.java b/src/main/java/me/kavin/piped/utils/ResponseHelper.java index 08506ef..4f273c0 100644 --- a/src/main/java/me/kavin/piped/utils/ResponseHelper.java +++ b/src/main/java/me/kavin/piped/utils/ResponseHelper.java @@ -223,15 +223,30 @@ public class ResponseHelper { Multithreading.runAsync(() -> { - me.kavin.piped.utils.obj.db.Channel channel = DatabaseHelper.getChannelFromId(info.getId()); + var channel = DatabaseHelper.getChannelFromId(info.getId()); try (StatelessSession s = DatabaseSessionFactory.createStatelessSession()) { if (channel != null) { - if (channel.isVerified() != info.isVerified() - || !channel.getUploaderAvatar().equals(info.getAvatarUrl())) { + + boolean modified = false; + + if (channel.isVerified() != info.isVerified()) { channel.setVerified(info.isVerified()); + modified = true; + } + + if (!channel.getUploaderAvatar().equals(info.getAvatarUrl())) { channel.setUploaderAvatar(info.getAvatarUrl()); + modified = true; + } + + if (!channel.getUploader().equals(info.getName())) { + channel.setUploader(info.getName()); + modified = true; + } + + if (modified) { var tr = s.beginTransaction(); s.update(channel); tr.commit();