SHA256
Исправить edit/delete сообщений, упростить вкладки каналов и улучшить автоскролл DM
This commit is contained in:
+14
-1
@@ -410,10 +410,23 @@ public final class Net_AddBlock_Handler implements JsonMessageHandler {
|
||||
|
||||
// target columns (optional)
|
||||
if (block.body instanceof BodyHasTarget t) {
|
||||
String targetBchName = t.toBchName();
|
||||
int type = block.type & 0xFFFF;
|
||||
int sub = block.subType & 0xFFFF;
|
||||
boolean isTextEdit = type == 1
|
||||
&& (sub == (MsgSubType.TEXT_EDIT_POST & 0xFFFF) || sub == (MsgSubType.TEXT_EDIT_REPLY & 0xFFFF));
|
||||
if (isTextEdit && (targetBchName == null || targetBchName.isBlank())) {
|
||||
targetBchName = blockchainName;
|
||||
}
|
||||
|
||||
be.setToLogin(t.toLogin());
|
||||
be.setToBchName(t.toBchName());
|
||||
be.setToBchName(targetBchName);
|
||||
be.setToBlockNumber(t.toBlockGlobalNumber());
|
||||
be.setToBlockHash(t.toBlockHashBytes());
|
||||
|
||||
if (isTextEdit && (be.getToLogin() == null || be.getToLogin().isBlank()) && targetBchName != null && !targetBchName.isBlank()) {
|
||||
be.setToLogin(BlockchainNameUtil.loginFromBlockchainName(targetBchName));
|
||||
}
|
||||
}
|
||||
|
||||
// edit helper (optional): если TEXT_EDIT_* — это "редактирование блока цели"
|
||||
|
||||
+5
-4
@@ -218,16 +218,17 @@ final class ChannelsReadSupport {
|
||||
SELECT login,bch_name,block_number,block_hash,block_bytes
|
||||
FROM blocks
|
||||
WHERE bch_name=? AND msg_type=? AND msg_sub_type=?
|
||||
AND to_bch_name=? AND to_block_number=? AND to_block_hash=?
|
||||
AND to_block_number=? AND to_block_hash=?
|
||||
AND (to_bch_name=? OR to_bch_name IS NULL OR to_bch_name='')
|
||||
ORDER BY block_number ASC
|
||||
""";
|
||||
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
||||
ps.setString(1, ownerBch);
|
||||
ps.setInt(2, MSG_TYPE_TEXT);
|
||||
ps.setInt(3, MsgSubType.TEXT_EDIT_POST);
|
||||
ps.setString(4, ownerBch);
|
||||
ps.setInt(5, originalBlock);
|
||||
ps.setBytes(6, originalHash);
|
||||
ps.setInt(4, originalBlock);
|
||||
ps.setBytes(5, originalHash);
|
||||
ps.setString(6, ownerBch);
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
List<PostBlock> out = new ArrayList<>();
|
||||
while (rs.next()) {
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ public class Net_GetChannelMessages_Handler implements JsonMessageHandler {
|
||||
v1.setCreatedAtMs(postText.createdAtMs);
|
||||
versionsOut.add(v1);
|
||||
|
||||
List<ChannelsReadSupport.PostBlock> edits = ChannelsReadSupport.versionsForPost(c, ownerBch, post.blockNumber, post.blockHash);
|
||||
List<ChannelsReadSupport.PostBlock> edits = ChannelsReadSupport.versionsForPost(c, post.bchName, post.blockNumber, post.blockHash);
|
||||
for (ChannelsReadSupport.PostBlock edit : edits) {
|
||||
ChannelsReadSupport.TextInfo editText = ChannelsReadSupport.parseTextAndTime(edit.blockBytes);
|
||||
Net_GetChannelMessages_Response.VersionItem ve = new Net_GetChannelMessages_Response.VersionItem();
|
||||
|
||||
+5
-4
@@ -196,15 +196,16 @@ public class Net_GetMessageThread_Handler implements JsonMessageHandler {
|
||||
SELECT login,bch_name,block_number,block_hash,block_bytes,to_bch_name,to_block_number,to_block_hash,line_code,msg_sub_type
|
||||
FROM blocks
|
||||
WHERE bch_name=? AND msg_type=1 AND msg_sub_type=?
|
||||
AND to_bch_name=? AND to_block_number=? AND to_block_hash=?
|
||||
AND to_block_number=? AND to_block_hash=?
|
||||
AND (to_bch_name=? OR to_bch_name IS NULL OR to_bch_name='')
|
||||
ORDER BY block_number ASC
|
||||
""";
|
||||
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
||||
ps.setString(1, bch);
|
||||
ps.setInt(2, subType);
|
||||
ps.setString(3, bch);
|
||||
ps.setInt(4, targetBlock);
|
||||
ps.setBytes(5, targetHash);
|
||||
ps.setInt(3, targetBlock);
|
||||
ps.setBytes(4, targetHash);
|
||||
ps.setString(5, bch);
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
List<PostRow> out = new ArrayList<>();
|
||||
while (rs.next()) out.add(mapRow(rs));
|
||||
|
||||
Reference in New Issue
Block a user