projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Check a reply’s post and its Sone before using those values.
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
template
/
ReplyAccessor.java
diff --git
a/src/main/java/net/pterodactylus/sone/template/ReplyAccessor.java
b/src/main/java/net/pterodactylus/sone/template/ReplyAccessor.java
index
53c5448
..
1e54d53
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/template/ReplyAccessor.java
+++ b/
src/main/java/net/pterodactylus/sone/template/ReplyAccessor.java
@@
-21,8
+21,8
@@
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.data.Reply;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.util.template.Accessor;
import net.pterodactylus.sone.data.Reply;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.util.template.Accessor;
-import net.pterodactylus.util.template.DataProvider;
import net.pterodactylus.util.template.ReflectionAccessor;
import net.pterodactylus.util.template.ReflectionAccessor;
+import net.pterodactylus.util.template.TemplateContext;
/**
* {@link Accessor} implementation that adds a couple of properties to
/**
* {@link Accessor} implementation that adds a couple of properties to
@@
-49,15
+49,19
@@
public class ReplyAccessor extends ReflectionAccessor {
* {@inheritDoc}
*/
@Override
* {@inheritDoc}
*/
@Override
- public Object get(
DataProvider dataProvider
, Object object, String member) {
+ public Object get(
TemplateContext templateContext
, Object object, String member) {
Reply reply = (Reply) object;
if ("likes".equals(member)) {
return core.getLikes(reply);
} else if (member.equals("liked")) {
Reply reply = (Reply) object;
if ("likes".equals(member)) {
return core.getLikes(reply);
} else if (member.equals("liked")) {
- Sone currentSone = (Sone)
dataProvider.getData
("currentSone");
+ Sone currentSone = (Sone)
templateContext.get
("currentSone");
return (currentSone != null) && (currentSone.isLikedReplyId(reply.getId()));
return (currentSone != null) && (currentSone.isLikedReplyId(reply.getId()));
+ } else if (member.equals("new")) {
+ return core.isNewReply(reply.getId());
+ } else if (member.equals("loaded")) {
+ return reply.getSone() != null;
}
}
- return super.get(
dataProvider
, object, member);
+ return super.get(
templateContext
, object, member);
}
}
}
}