Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Events to not age after getAge() ist called. #404

Open
vorletzter opened this issue Dec 8, 2018 · 2 comments
Open

Events to not age after getAge() ist called. #404

vorletzter opened this issue Dec 8, 2018 · 2 comments
Labels

Comments

@vorletzter
Copy link

Vector-Android does not seem to use that function to get the Age of an Event. Regardless. It seems kinda counterproductive if an Object does not Age further, after getAge() is called for the first time.

Is there a special reason for this behavior?

if (null != age) {
     return age;
}

@bmarty
Copy link
Contributor

bmarty commented Dec 10, 2018

Event.age which is of type Long (and not long) is just of cache of age get from unsigned data. Or maybe I do not understand your question?

@vorletzter
Copy link
Author

vorletzter commented Dec 11, 2018

@bmarty thank you for your answer. I am still trying to get to terms with SDK. Unfortunately there seems to be a big lack of how to use the SDK. The readme.md is a bit unspecific on most subjects and (at least to me) riot-vector is quite a beast to be used as an example - to much "glossy"-Stuff going on to keep track of the actual usage of the SDK. At least to my self-taught Java/Android Skills :) So, i hope, that this is not a stupid Question.

I tried to write a Comparator to sort Rooms according to last received Event using (RoomSumary.class).getLatestEvent().getAge(). I expected getAge() to return the current Age of the Event. But after the first call to getAge() the Age never changes, because it is only calculated for the first call.

Lets say i call getAge() on am Event and it returns 200.
As the Eventstream progresses i would expect getAge() to return a greater Value, but it will always return 200, because of "if (null != age)". So after the first call the Event never ages.

Unlike for example the getOriginServerTs() i would expect getAge() to always return the current Age of the Event. If i would call getAge() on a living object i would expect a different result if would call the same function a year later on the same beeing. So this is probably more a questions towards the semantics of the Method().

This is probably not a bug per se, because riot-vector uses getOriginServerTs() to sort rooms ( https://github.com/vector-im/riot-android/blob/c402a03977856f38bee70aaf72d57eda7b314fe8/vector/src/main/java/im/vector/util/RoomUtils.java#L237 ), but i would expect a different behavior.
According to grep -r "getAge()" on riot-vector getAge() is only used to determine if an Event is an DummyEvent. But to SDKs Users this probably is an unexpected Behavior.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants