-- vim: ft=terra
local modes = lib.enum {'follow','mutual','srvlocal','fediglobal','circle'}
local terra 
render_timeline(co: &lib.srv.convo, modestr: lib.mem.ref(int8))
	var mode = modes.srvlocal
	var circle: uint64 = 0
	-- if     modestr:cmpl('local') then mode = modes.srvlocal
	-- elseif modestr:cmpl('mutual') then mode = modes.mutual
	-- elseif modestr:cmpl('global') then mode = modes.fediglobal
	-- elseif modestr:cmpl('circle') then mode = modes.circle
	-- end

	var stoptime = lib.osclock.time(nil)

	var posts = [lib.mem.vec(lib.mem.ptr(lib.store.post))] { 
		sz = 0, run = 0
	}
	if mode == modes.follow then
	elseif mode == modes.srvlocal then
		posts = co.srv:timeline_instance_fetch(lib.store.range {
			mode = 1; -- T->I
			from_time = stoptime;
			to_idx = 64;
		})
	elseif mode == modes.fediglobal then
	elseif mode == modes.circle then
	end

	var acc: lib.str.acc acc:pool(&co.srv.pool,1024)
	acc:lpush('<div id="tl" data-live="10">')
	var newest: lib.store.timepoint = 0
	for i = 0, posts.sz do
		lib.render.tweet(co, posts(i).ptr, &acc)
		var t = lib.math.biggest(lib.math.biggest(posts(i).ptr.posted, posts(i).ptr.discovered),posts(i).ptr.edited)
		if t > newest then newest = t end
		posts(i):free()
	end
	posts:free()
	acc:lpush('</div>')

	var doc = [lib.srv.convo.page] {
		title = lib.str.plit'timeline';
		body = acc:finalize();
		class = lib.str.plit'timeline';
		cache = false;
	}
	co:livepage(doc,newest)
	--doc.body:free()
end
return render_timeline
