mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2024-11-22 08:07:30 +00:00
Automatically update whether profiles are private
This commit is contained in:
parent
3cbe4647e1
commit
a8ca233027
@ -1,6 +1,6 @@
|
||||
const {Feed} = require("feed")
|
||||
const constants = require("../constants")
|
||||
const config = require("../../../config")
|
||||
const db = require("../db")
|
||||
const TimelineEntry = require("./TimelineEntry")
|
||||
const InstaCache = require("../cache")
|
||||
const collectors = require("../collectors")
|
||||
@ -50,6 +50,15 @@ class Timeline {
|
||||
}
|
||||
|
||||
addPage(page) {
|
||||
// update whether the user should be private
|
||||
if (this.pages.length === 0 && page.count > 0) { // this is the first page, and user has posted
|
||||
const shouldBePrivate = page.edges.length === 0
|
||||
if (shouldBePrivate !== this.user.data.is_private) {
|
||||
db.prepare("UPDATE Users SET is_private = ? WHERE user_id = ?").run(+shouldBePrivate, this.user.data.id)
|
||||
this.user.data.is_private = shouldBePrivate
|
||||
}
|
||||
}
|
||||
// add the page
|
||||
this.pages.push(transformEdges(page.edges))
|
||||
this.page_info = page.page_info
|
||||
this.user.posts = page.count
|
||||
|
@ -78,18 +78,15 @@ html
|
||||
|
||||
- const hasPosts = !user.data.is_private && user.timeline.pages.length && user.timeline.pages[0].length
|
||||
main(class=hasPosts ? "" : "no-posts")#timeline.timeline
|
||||
if !user.data.is_private
|
||||
if hasPosts
|
||||
each page, pageIndex in user.timeline.pages
|
||||
+timeline_page(page, pageIndex)
|
||||
+next_page_button(user, url)
|
||||
|
||||
else
|
||||
div
|
||||
div.page-number
|
||||
span.number No posts.
|
||||
|
||||
span.number
|
||||
if user.data.is_private
|
||||
| Profile is private.
|
||||
else
|
||||
div
|
||||
div.page-number
|
||||
span.number Profile is private.
|
||||
| No posts.
|
||||
|
Loading…
Reference in New Issue
Block a user