mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2024-11-22 16:17:29 +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 {Feed} = require("feed")
|
||||||
const constants = require("../constants")
|
const constants = require("../constants")
|
||||||
const config = require("../../../config")
|
const db = require("../db")
|
||||||
const TimelineEntry = require("./TimelineEntry")
|
const TimelineEntry = require("./TimelineEntry")
|
||||||
const InstaCache = require("../cache")
|
const InstaCache = require("../cache")
|
||||||
const collectors = require("../collectors")
|
const collectors = require("../collectors")
|
||||||
@ -50,6 +50,15 @@ class Timeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addPage(page) {
|
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.pages.push(transformEdges(page.edges))
|
||||||
this.page_info = page.page_info
|
this.page_info = page.page_info
|
||||||
this.user.posts = page.count
|
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
|
- const hasPosts = !user.data.is_private && user.timeline.pages.length && user.timeline.pages[0].length
|
||||||
main(class=hasPosts ? "" : "no-posts")#timeline.timeline
|
main(class=hasPosts ? "" : "no-posts")#timeline.timeline
|
||||||
if !user.data.is_private
|
|
||||||
if hasPosts
|
if hasPosts
|
||||||
each page, pageIndex in user.timeline.pages
|
each page, pageIndex in user.timeline.pages
|
||||||
+timeline_page(page, pageIndex)
|
+timeline_page(page, pageIndex)
|
||||||
+next_page_button(user, url)
|
+next_page_button(user, url)
|
||||||
|
|
||||||
else
|
else
|
||||||
div
|
div
|
||||||
div.page-number
|
div.page-number
|
||||||
span.number No posts.
|
span.number
|
||||||
|
if user.data.is_private
|
||||||
|
| Profile is private.
|
||||||
else
|
else
|
||||||
div
|
| No posts.
|
||||||
div.page-number
|
|
||||||
span.number Profile is private.
|
|
||||||
|
Loading…
Reference in New Issue
Block a user