-- 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:init(1024)
	for i = 0, posts.sz do
		lib.render.tweet(co, posts(i).ptr, &acc)
		posts(i):free()
	end
	posts:free()

	var doc = data.view.docskel {
		instance = co.srv.cfg.instance;
		title = lib.str.plit'timeline';
		body = acc:finalize();
		class = lib.str.plit'timeline';
		navlinks = co.navbar;
	}
	var hdrs = array(
		lib.http.header { 'Content-Type', 'text/html; charset=UTF-8' }
	)
	doc:send(co.con,200,[lib.mem.ptr(lib.http.header)] {ct = 1, ptr = &hdrs[0]})
	doc.body:free()
end
return render_timeline
