|
|
Here is the process:
|
|
|
I'm not seeing any green icons, despite not being here for a week. (Luckily, I remember my last visit, so I can sort out the new posts manually - this time.) |
|
|
No problems here, but I love an "Mark all topics read"-button. |
|
|
It's happens to me when I reply to a topic, it appears anyway green, I have to read it again to turn it gray. |
|
|
>> Aquilax Yes, that's the bug I mean.
|
|
|
I've noticed weird things in the past as well. I inherited this code from "beast" (rails based forum software). I've not really dug into it. So I'm not really sure what it is doing internally to track when a post is marked as read or not. I'll check into it tonight. |
|
|
It seems to me like there are no green icons anymore at all... /edit: just after I've written that, it seems to be fixed.
/edit: Now it's all back to gray. I have not looked at all threads... |
|
|
I'm using a saved session that opens pages for all of the topic lists at the same time. This time, one list had green icons, and the others didn't. Weird. |
|
|
I'm not really sure what it is doing internallyAn educated guess: It's storing only one "last visited" value, rather than one per forum, i.e., if it's been 24 hours since my last visit, when I go to /forums/1 it correctly flags posts from the last 24 hours, but if I were to go to /forums/2 five minutes later, it'd only flag posts from the 5 minutes since I hit /forums/1. This is why I see only one forum flagged properly; I use a bookmark that opens all the forums in separate tabs simultaneously, and the one marked properly is whichever request hits the server first. |
|
|
i think i got it
|
|
|
I'm sure there are bugs here since I've never touched this code: Whenever you view a topic, it modifies your session by storing the last time the topic.id was viewed.
(session[:topics] ||= {})[@topic.id] = Time.now.utc if logged_in?
The session is stored in a cookie (signed so it cannot be tamper with), so there could be issues with tabs (although I think rails is designed so it won't be) Then when a list of topics is rendered if the following is true then the topic has "new activity" and is marked in green. topic.replied_at > (session[:topics][topic.id] || last_active) Whenever a topic is updated the replied_at is updated. last_active is defined as: session[:last_active] ||= Time.now.utc I hadn't read the code before and nothing seems to stick out... Then again I'm exhausted :( |
|
|
If you aren't used to ruby ||= is only define this if it isn't already. c = 3 c ||= 1 Would leave c equal to 3, but if c was nil/null/false/... then it would become 1. |
|
|
To help figure this out, if you append a query param of debug=1 to the end of any URL it will output some of the session information: last_active and topics |
|
|
Damn I wish I knew some Ruby, or had spare time to learn it. |
|
|
Yeah if I reply to a topic, then go back to the forum it was posted in, it's green until I read it again. |
|
|
append a query param of debug=1Okay, I made a new bookmark using that; I'll let you know what happens when I use it next time (gotta have some new messages). |
|
|
clicking as fast as possible...
http://userscripts.org/topics/18269?debug=1 (kept unread)
* last_active: Mon, 24 Nov 2008 23:15:42 CST -06:00
* topics: {18240=>Tue Nov 25 12:52:22 UTC 2008, 18224=>Tue Nov 25 12:36:37 UTC 2008, 18269=>Tue Nov 25 18:56:11 UTC 2008}
http://userscripts.org/topics/18240?debug=1 (kept unread)
* last_active: Mon, 24 Nov 2008 23:15:42 CST -06:00
* topics: {18240=>Tue Nov 25 18:56:12 UTC 2008, 18224=>Tue Nov 25 12:36:37 UTC 2008}
http://userscripts.org/topics/18224?debug=1 (changed to read)
* last_active: Mon, 24 Nov 2008 23:15:42 CST -06:00
* topics: {18240=>Tue Nov 25 12:52:22 UTC 2008, 18224=>Tue Nov 25 18:56:13 UTC 2008}
=============================================================================== waiting the topic to load...
http://userscripts.org/topics/18262?debug=1 (changed to read)
* last_active: Mon, 24 Nov 2008 23:15:42 CST -06:00
* topics: {9505=>Tue Nov 25 12:58:21 UTC 2008, 18262=>Tue Nov 25 19:08:11 UTC 2008, 18171=>Tue Nov 25 12:58:19 UTC 2008}
http://userscripts.org/topics/18171?debug=1 (changed to read)
* last_active: Mon, 24 Nov 2008 23:15:42 CST -06:00
* topics: {9505=>Tue Nov 25 12:58:21 UTC 2008, 18262=>Tue Nov 25 19:08:11 UTC 2008, 18171=>Tue Nov 25 19:08:22 UTC 2008}
http://userscripts.org/topics/9505?debug=1 (changed to read)
* last_active: Mon, 24 Nov 2008 23:15:42 CST -06:00
* topics: {9505=>Tue Nov 25 19:08:29 UTC 2008, 18262=>Tue Nov 25 19:08:11 UTC 2008, 18171=>Tue Nov 25 19:08:22 UTC 2008}
|
|
|
one obvious bug now that I've gotten some sleep is that when you post a reply on a topic it should set your last seen time for the topic to the time of your reply |
|
|
Okay,
, despite there being new messages on three different topics since I last viewed the page in question, about 12 hours ago.
, despite there being new messages on two different topics.
, despite there being new messages on three different topics. I suspect I'm misinterpreting how this is supposed to work, but it strikes me as wrong that my access of |
|
|
session[:last_active] ||= Time.now.utc should mean that last_active is only changed when it isn't already set. I don't see anything else that modifies it. I think that it only gets set the first time you visit. Long day - will dive into this more tomorrow. |
|
|
I have also a new bug, now when I'm on the main page of the forums (http://userscripts.org/forums) and I open one forum in another tab and reload the main page, the forum is marked as "read" even if I haven't still read any topic. Main page before opening a forum in a new tab:
* last_active: Tue, 25 Nov 2008 19:43:26 CST -06:00
Main page reloaded after just opening a forum in a new tab:
* last_active: Tue, 25 Nov 2008 19:43:26 CST -06:00
Main page reloaded after just opening a second forum in a new tab:
* last_active: Tue, 25 Nov 2008 19:43:26 CST -06:00
Main page reloaded after just opening a third forum in a new tab:
* last_active: Tue, 25 Nov 2008 19:43:26 CST -06:00
|
|
|
With todays foray into the forums:
, which is actually the correct result (for a change).
, despite there being new messages on four different topics.
, despite there being new messages on three different topics. And I didn't notice this until now, but if |
|
|
this code is horrible - it just gets worse: the session[:forums] and session[:topics] share the same values (eg, it is 1 hash instead of 2 distinct hashes). That is why @ScroogeMcPump was getting that Topics 1,2,3 were set when he visited a forum! This code HAS to be rewritten - and stored the view time in the database... |
|
|
I think good catch, but also a lot off work. |
|
|
I was looking at what phpBB did - and it seems to not create any database indexes! That's crazy. The basic idea is pretty simple - perhaps I'll implement it and do a few EXPLAINs to see if the indexes (on both topic_id, user_id) is the right idea or if it is naive since I've never implemented this. |