Merge pull request #403 from TeamPiped/channel-name-updates

Add channel name updates when loading channels
This commit is contained in:
Kavin 2022-10-29 21:19:33 +01:00 committed by GitHub
commit b62da8a8d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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();