Icon to show or hide announces

merge-requests/30/head
Bob Mottram 2024-05-13 15:58:14 +01:00
parent 15f8532c2f
commit 6c07ac40d0
2 changed files with 30 additions and 7 deletions

View File

@ -410,6 +410,7 @@ class PubServerUnitTest(PubServer):
class EpicyonServer(ThreadingHTTPServer): class EpicyonServer(ThreadingHTTPServer):
starting_daemon = True starting_daemon = True
hide_announces = {}
no_of_books = 0 no_of_books = 0
max_api_blocks = 32000 max_api_blocks = 32000
block_federated_endpoints = None block_federated_endpoints = None
@ -801,6 +802,9 @@ def run_daemon(accounts_data_dir: str,
# for each account whether to hide announces # for each account whether to hide announces
httpd.hide_announces = {} httpd.hide_announces = {}
hide_announces_filename = data_dir(base_dir) + '/hide_announces.json'
if os.path.isfile(hide_announces_filename):
httpd.hide_announces = load_json(hide_announces_filename)
# number of book events which show on profile screens # number of book events which show on profile screens
httpd.no_of_books = no_of_books httpd.no_of_books = no_of_books

View File

@ -85,6 +85,7 @@ from httpcodes import http_304
from httpcodes import http_400 from httpcodes import http_400
from httpcodes import http_503 from httpcodes import http_503
from httpcodes import write2 from httpcodes import write2
from utils import save_json
from utils import data_dir from utils import data_dir
from utils import user_agent_domain from utils import user_agent_domain
from utils import local_network_host from utils import local_network_host
@ -3013,6 +3014,24 @@ def daemon_http_get(self) -> None:
'_GET', 'hashtag search done', '_GET', 'hashtag search done',
self.server.debug) self.server.debug)
# hide announces button in the web interface
if html_getreq and users_in_path and \
self.path.endswith('/hideannounces') and \
authorized:
nickname = self.path.split('/users/')[1]
if '/' in nickname:
nickname = nickname.split('/')[0]
if self.server.hide_announces.get('nickname'):
del self.server.hide_announces['nickname']
else:
self.server.hide_announces['nickname'] = True
hide_announces_filename = \
data_dir(self.server.base_dir) + '/hide_announces.json'
save_json(self.server.hide_announces, hide_announces_filename)
self.path = get_default_path(self.server.media_instance,
self.server.blogs_instance,
nickname)
# show or hide buttons in the web interface # show or hide buttons in the web interface
if html_getreq and users_in_path and \ if html_getreq and users_in_path and \
self.path.endswith('/minimal') and \ self.path.endswith('/minimal') and \
@ -3020,13 +3039,13 @@ def daemon_http_get(self) -> None:
nickname = self.path.split('/users/')[1] nickname = self.path.split('/users/')[1]
if '/' in nickname: if '/' in nickname:
nickname = nickname.split('/')[0] nickname = nickname.split('/')[0]
not_min = not is_minimal(self.server.base_dir, not_min = not is_minimal(self.server.base_dir,
self.server.domain, nickname) self.server.domain, nickname)
set_minimal(self.server.base_dir, set_minimal(self.server.base_dir,
self.server.domain, nickname, not_min) self.server.domain, nickname, not_min)
self.path = get_default_path(self.server.media_instance, self.path = get_default_path(self.server.media_instance,
self.server.blogs_instance, self.server.blogs_instance,
nickname) nickname)
# search for a fediverse address, shared item or emoji # search for a fediverse address, shared item or emoji
# from the web interface by selecting search icon # from the web interface by selecting search icon