diff --git a/briar-android/src/org/briarproject/android/privategroup/conversation/GroupControllerImpl.java b/briar-android/src/org/briarproject/android/privategroup/conversation/GroupControllerImpl.java index e0ba5d3d89fcd318a334117813d2ccebe90de489..1a11bd88ef5a23e35d0e424ecacd76e3dd75cd17 100644 --- a/briar-android/src/org/briarproject/android/privategroup/conversation/GroupControllerImpl.java +++ b/briar-android/src/org/briarproject/android/privategroup/conversation/GroupControllerImpl.java @@ -6,6 +6,7 @@ import org.briarproject.android.api.AndroidNotificationManager; import org.briarproject.android.controller.handler.ResultExceptionHandler; import org.briarproject.android.privategroup.conversation.GroupController.GroupListener; import org.briarproject.android.threaded.ThreadListControllerImpl; +import org.briarproject.api.clients.MessageTracker.GroupCount; import org.briarproject.api.crypto.CryptoExecutor; import org.briarproject.api.db.DatabaseExecutor; import org.briarproject.api.db.DbException; @@ -130,15 +131,10 @@ public class GroupControllerImpl extends MessageId parentId = null; MessageId previousMsgId = privateGroupManager.getPreviousMsgId(getGroupId()); - // timestamp must be greater than the timestamps - // of the member's previous message... - long timestamp = privateGroupManager - .getMessageTimestamp(previousMsgId); - // ...and the parent post, if any - if (parentItem != null) { - timestamp = max(parentItem.getTimestamp(), timestamp); - parentId = parentItem.getId(); - } + GroupCount count = + privateGroupManager.getGroupCount(getGroupId()); + long timestamp = count.getLatestMsgTime(); + if (parentItem != null) parentId = parentItem.getId(); timestamp = max(clock.currentTimeMillis(), timestamp + 1); createMessage(body, timestamp, parentId, author, previousMsgId, handler); diff --git a/briar-api/src/org/briarproject/api/privategroup/PrivateGroupManager.java b/briar-api/src/org/briarproject/api/privategroup/PrivateGroupManager.java index 636678052d41359dd1ba0c8aefcc04a823167807..89802684583bcac79facec6d96e3d110ab514265 100644 --- a/briar-api/src/org/briarproject/api/privategroup/PrivateGroupManager.java +++ b/briar-api/src/org/briarproject/api/privategroup/PrivateGroupManager.java @@ -51,12 +51,6 @@ public interface PrivateGroupManager extends MessageTracker { */ MessageId getPreviousMsgId(GroupId g) throws DbException; - /** - * Returns the timestamp of the message with the given ID - */ - // TODO change to getPreviousMessageHeader() - long getMessageTimestamp(MessageId id) throws DbException; - /** * Marks the group with GroupId g as resolved */ diff --git a/briar-core/src/org/briarproject/privategroup/PrivateGroupManagerImpl.java b/briar-core/src/org/briarproject/privategroup/PrivateGroupManagerImpl.java index 5ff1193f93ed4f4534f32d99a78a77b4908aa2f4..0a8c436ec0610b12d5a82d0cf48e2b0ffeef9205 100644 --- a/briar-core/src/org/briarproject/privategroup/PrivateGroupManagerImpl.java +++ b/briar-core/src/org/briarproject/privategroup/PrivateGroupManagerImpl.java @@ -192,16 +192,6 @@ public class PrivateGroupManagerImpl extends BdfIncomingMessageHook implements txn.attach(e); } - @Override - public long getMessageTimestamp(MessageId id) throws DbException { - try { - BdfDictionary d = clientHelper.getMessageMetadataAsDictionary(id); - return d.getLong(KEY_TIMESTAMP); - } catch (FormatException e) { - throw new DbException(e); - } - } - @Override public GroupMessageHeader addLocalMessage(GroupMessage m) throws DbException {