fix bugs
This commit is contained in:
@@ -206,11 +206,9 @@ public class AddMembersController {
|
||||
|
||||
private Image loadAvatar(String path) {
|
||||
try {
|
||||
// 1) اگر ریسورس داخلی باشد
|
||||
var in = getClass().getResourceAsStream(path);
|
||||
if (in != null) return new Image(in);
|
||||
|
||||
// 2) اگر URL کامل یا file URI
|
||||
return new Image(path, true);
|
||||
} catch (Exception e) {
|
||||
return new Image(
|
||||
@@ -233,7 +231,6 @@ public class AddMembersController {
|
||||
|
||||
List<String> ids = selectedContacts.stream().map(Contact::getId).toList();
|
||||
|
||||
// تلاش برای batch
|
||||
JSONObject batchReq = new JSONObject()
|
||||
.put("action", "add_members_to_group")
|
||||
.put("group_id", groupInternalId.toString())
|
||||
@@ -248,11 +245,10 @@ public class AddMembersController {
|
||||
return;
|
||||
}
|
||||
|
||||
// fallback: تکبهتک
|
||||
boolean allOk = true;
|
||||
for (String uid : ids) {
|
||||
JSONObject single = new JSONObject()
|
||||
.put("action", "add_member_to_group")
|
||||
.put("action", "add_members_to_group")
|
||||
.put("group_id", groupInternalId.toString())
|
||||
.put("user_id", uid);
|
||||
JSONObject r = ActionHandler.sendWithResponse(single);
|
||||
|
||||
@@ -14,6 +14,8 @@ import org.to.telegramfinalproject.Client.ActionHandler;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -116,13 +118,27 @@ public class ManageGroupController {
|
||||
groupIdField.setText(originalGroupId);
|
||||
|
||||
if (!originalImageUrl.isBlank()) {
|
||||
groupImage.setImage(new Image(originalImageUrl, true));
|
||||
String uri = resolveLocalUri(originalImageUrl);
|
||||
if (uri != null) {
|
||||
groupImage.setImage(new Image(uri, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
adminCount.setText(String.valueOf(countRole(data, "admin") + 1));
|
||||
memberCount.setText(String.valueOf(countRole(data, "member") + Integer.parseInt(adminCount.getText())));
|
||||
}
|
||||
|
||||
private String resolveLocalUri(String raw) {
|
||||
if (raw == null || raw.isBlank()) return null;
|
||||
if (raw.startsWith("file:/") || raw.startsWith("http")) return raw;
|
||||
|
||||
Path base = Paths.get(System.getProperty("user.dir"), "uploads");
|
||||
Path resolved = base.resolve(raw.startsWith("/") ? raw.substring(1) : raw)
|
||||
.normalize();
|
||||
return resolved.toUri().toString(); // file:///C:/.../uploads/avatars/2025-09-05/...
|
||||
}
|
||||
|
||||
private int countRole(JSONObject groupData, String role) {
|
||||
var arr = groupData.optJSONArray("members");
|
||||
if (arr == null) return 0;
|
||||
|
||||
Reference in New Issue
Block a user