Skip to content
This repository has been archived by the owner on Oct 3, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1033 from Kamuso/dev/hide-bins
Browse files Browse the repository at this point in the history
Client: Hide deleted posts
  • Loading branch information
bakape authored Apr 19, 2019
2 parents 3b77543 + def63c6 commit 092343b
Show file tree
Hide file tree
Showing 16 changed files with 77 additions and 3 deletions.
1 change: 1 addition & 0 deletions client/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface Options extends ChangeEmitter {
bgVideo: string
bgMute: boolean
horizontalPosting: boolean
hideBinned: boolean
hideRecursively: boolean
replyRight: boolean
galleryModeToggle: boolean
Expand Down
22 changes: 20 additions & 2 deletions client/options/loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// module loops through the post models and calls the appropriate methods in
// batches.

import { posts, page } from "../state"
import { posts, page, hidden } from "../state"
import options from "."
import { Post } from "../posts"
import { Post, hideRecursively } from "../posts"
import { fileTypes } from "../common"
import { trigger } from "../util";

// Listen for changes on the options object and call appropriate handlers on
// all applicable posts
Expand All @@ -16,6 +17,7 @@ export default () => {
spoilers: toggleSpoilers,
autogif: toggleAutoGIF,
anonymise: toggleAnonymisation,
hideBinned: toggleHideBinned,
relativeTime: renderTime,
}
for (let key in handlers) {
Expand Down Expand Up @@ -103,6 +105,22 @@ function toggleAnonymisation() {
)
}

// Hide all deleted posts
function toggleHideBinned() {
if (!options.hideBinned) {
return;
}
loopPosts(
( post ) => {
return post.isDeleted();
},
( post ) => {
hideRecursively(post);
}
)
trigger("renderHiddenCount", hidden.size)
}

// Rerender all timestamps on posts, if set to relative time
function renderTime() {
for (let { view } of posts) {
Expand Down
2 changes: 2 additions & 0 deletions client/options/specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export const specs: { [id: string]: OptionSpec } = {
},
// Anonymise all poster names
anonymise: {},
// Hide all deleted posts
hideBinned: {},
// Hide posts that linked to a hidden post
hideRecursively: {},
// Expand post links inline
Expand Down
11 changes: 10 additions & 1 deletion client/posts/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ export class Post extends Model implements PostData {
constructor(attrs: PostData) {
super()
extend(this, attrs)
this.seenOnce = seenPosts.has(this.id)
if (options.hideBinned && this.isDeleted()) {
hidden.add(this.id)
storeSeenPost(this.id, this.op)
this.seenOnce = true
} else{
this.seenOnce = seenPosts.has(this.id)
}

// All kinds of interesting races can happen, so best ensure a model
// always has the state object defined
Expand Down Expand Up @@ -213,6 +219,9 @@ export class Post extends Model implements PostData {
case ModerationAction.deletePost:
if (!mine.has(this.id)) {
this.view.el.classList.add("deleted");
if (options.hideBinned) {
hideRecursively(this);
}
}
break;
case ModerationAction.deleteImage:
Expand Down
3 changes: 3 additions & 0 deletions client/posts/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export default class PostView extends ImageHandler {
}
if (model.isDeleted()) {
attrs.class += " deleted"
if (options.hideBinned) {
attrs.class += " hidden"
}
}
attrs.tag = "article"
attrs.id = "p" + model.id
Expand Down
4 changes: 4 additions & 0 deletions static/src/lang/en_GB/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@
"Hidden: 0",
"Clear hidden posts"
],
"hideBinned": [
"Hide Deleted Posts",
"Hide all posts that have been deleted"
],
"hideNSFW": [
"Hide NSFW on /all/",
"Hide boards tagged as not safe for work from the /all/ metaboard"
Expand Down
4 changes: 4 additions & 0 deletions static/src/lang/es_ES/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@
"Escondido: 0",
"Limpiar posts escondidos"
],
"hideBinned": [
"Hide Deleted Posts",
"Hide all posts that have been deleted"
],
"hideNSFW": [
"Hide NSFW on /all/",
"Hide boards tagged as not safe for work from the /all/ metaboard"
Expand Down
4 changes: 4 additions & 0 deletions static/src/lang/fr_FR/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@
"Caché : 0",
"Remet à zéro la liste des messages cachés"
],
"hideBinned": [
"Hide Deleted Posts",
"Hide all posts that have been deleted"
],
"hideNSFW": [
"Cacher le NSFW sur /all/",
"Cache les planches avec du contenu peu recommandable sur /all/"
Expand Down
4 changes: 4 additions & 0 deletions static/src/lang/nl_NL/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@
"Verborgen: 0",
"Verwijder verborgen berichten"
],
"hideBinned": [
"Hide Deleted Posts",
"Hide all posts that have been deleted"
],
"hideNSFW": [
"NSFW verbergen op / alles /",
"Verberg boards die als niet veilig zijn gemarkeerd voor werk vanuit de / alles / metaboard"
Expand Down
4 changes: 4 additions & 0 deletions static/src/lang/pl_PL/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@
"Hidden: 0",
"Clear hidden posts"
],
"hideBinned": [
"Hide Deleted Posts",
"Hide all posts that have been deleted"
],
"hideNSFW": [
"Hide NSFW on /all/",
"Hide boards tagged as not safe for work from the /all/ metaboard"
Expand Down
4 changes: 4 additions & 0 deletions static/src/lang/pt_BR/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@
"Escondidos: 0",
"Limpa os posts escondidos"
],
"hideBinned": [
"Hide Deleted Posts",
"Hide all posts that have been deleted"
],
"hideNSFW": [
"Hide NSFW on /all/",
"Hide boards tagged as not safe for work from the /all/ metaboard"
Expand Down
4 changes: 4 additions & 0 deletions static/src/lang/ru_RU/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@
"Скрыто: 0",
"Очистить список скрытого"
],
"hideBinned": [
"Hide Deleted Posts",
"Hide all posts that have been deleted"
],
"hideNSFW": [
"Hide NSFW on /all/",
"Hide boards tagged as not safe for work from the /all/ metaboard"
Expand Down
4 changes: 4 additions & 0 deletions static/src/lang/sk_SK/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@
"Schovaných: 0",
"Vyčistiť zoznam schovaných plagátov"
],
"hideBinned": [
"Hide Deleted Posts",
"Hide all posts that have been deleted"
],
"hideNSFW": [
"Hide NSFW on /all/",
"Hide boards tagged as not safe for work from the /all/ metaboard"
Expand Down
4 changes: 4 additions & 0 deletions static/src/lang/tr_TR/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@
"Gizli: 0",
"Gizli girdileri temizle"
],
"hideBinned": [
"Hide Deleted Posts",
"Hide all posts that have been deleted"
],
"hideNSFW": [
"Hide NSFW on /all/",
"Hide boards tagged as not safe for work from the /all/ metaboard"
Expand Down
4 changes: 4 additions & 0 deletions static/src/lang/uk_UA/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@
"Сховано: 0",
"Очистити сховані пости"
],
"hideBinned": [
"Hide Deleted Posts",
"Hide all posts that have been deleted"
],
"hideNSFW": [
"Hide NSFW on /all/",
"Hide boards tagged as not safe for work from the /all/ metaboard"
Expand Down
1 change: 1 addition & 0 deletions templates/specs.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ var optionSpecs = [...][]inputSpec{
{ID: "notification"},
{ID: "watchThreadsOnReply"},
{ID: "anonymise"},
{ID: "hideBinned"},
{ID: "hideRecursively"},
{ID: "postInlineExpand"},
{ID: "relativeTime"},
Expand Down

0 comments on commit 092343b

Please sign in to comment.