Per 1 status mode implemented

This commit is contained in:
localhost_frssoft 2022-04-18 23:54:01 +03:00
parent 251cc25b30
commit 02c1c0b912
2 changed files with 58 additions and 18 deletions

View file

@ -1,6 +1,7 @@
{ {
"instance": "soc.phreedom.club", "instance": "soc.phreedom.club",
"max_statuses": 40, "max_statuses": 40,
"per_status_mode": false,
"enabled_nsfw": false, "enabled_nsfw": false,
"default_content_type": "text/markdown", "default_content_type": "text/markdown",
"default_visibility": "unlisted", "default_visibility": "unlisted",

View file

@ -15,6 +15,7 @@ statuses_separator=$(jj -i config.json statuses_separator)
reversed_statuses=$(jj -i config.json reversed_statuses) reversed_statuses=$(jj -i config.json reversed_statuses)
quoting_reply=$(jj -i config.json quoting_reply) quoting_reply=$(jj -i config.json quoting_reply)
copy_mentions=$(jj -i config.json copy_mentions) copy_mentions=$(jj -i config.json copy_mentions)
per_status_mode=$(jj -i config.json per_status_mode)
#[AUTH SECTION] #[AUTH SECTION]
mkdir -m 711 -p .app_sessions mkdir -m 711 -p .app_sessions
@ -340,6 +341,7 @@ statuses_render()
fi fi
if [ -n "$reblog" ]; then if [ -n "$reblog" ]; then
echo "| $boost_symbol $reblog $reblogacct" echo "| $boost_symbol $reblog $reblogacct"
id_status="$reblog"
fi fi
spoiler_text=$(echo "$status" | jj spoiler_text) spoiler_text=$(echo "$status" | jj spoiler_text)
if [ -n "$spoiler_text" ]; then if [ -n "$spoiler_text" ]; then
@ -353,6 +355,27 @@ statuses_render()
echo "$attachments" | tee -a attachments.m3u8 echo "$attachments" | tee -a attachments.m3u8
fi fi
echo "$statuses_separator" echo "$statuses_separator"
if [ "$per_status_mode" = 'true' ]; then
next=0
force_stop=0
while [ "$next" -eq 0 ]; do
per_status_menu=$(echo 'Next\nMedia\nShare and favorite\nShare\nFavorite\nReply\nBack' | fzy)
case "$per_status_menu" in
"Next") next=1; clear ;;
"Media")
for one_media in $attachments; do
mpv "$one_media"
done
;;
"Share and favorite") share_and_favorite_mode "$id_status" ;;
"Share") share_api_status "$id_status" ;;
"Favorite") favorite_api_status "$id_status" ;;
"Reply") reply_mode "$id_status" ;;
"Back") next=1; force_stop=1 ;;
esac
done
if [ "$force_stop" -eq 1 ]; then break; fi
fi
done done
} }
@ -445,11 +468,16 @@ timeline_menu()
json=$(timeline_api) json=$(timeline_api)
sub_menu_lvl=1 sub_menu_lvl=1
echo '#EXTM3U' > attachments.m3u8 echo '#EXTM3U' > attachments.m3u8
if [ "$per_status_mode" = 'true' ]; then
menuentryes='Prev\nNext\nMain menu'
else
menuentryes='Prev\nNext\nReply\nShare\nFavorite\nShare and favorite\nThread\nMain menu'
fi
while [ $sub_menu_lvl -eq 1 ]; do while [ $sub_menu_lvl -eq 1 ]; do
ids_massive=$(echo "$json" | jj -l \#.id | delq) ids_massive=$(echo "$json" | jj -l \#.id | delq)
jsonmassive=$json jsonmassive=$json
statuses_render statuses_render
menu=$(echo 'Prev\nNext\nReply\nShare\nFavorite\nShare and favorite\nThread\nMain menu' | fzy) menu=$(echo "$menuentryes" | fzy)
case $menu in case $menu in
"Prev") "Prev")
indexator=$(expr $(echo "$json" | jj \#) - 1) indexator=$(expr $(echo "$json" | jj \#) - 1)
@ -476,33 +504,44 @@ timeline_menu()
reply_mode() reply_mode()
{ {
echo 'Input id' if [ -n "$1" ]; then
read status_id reply_status=$(status_api_one "$1")
reply_status=$(status_api_one "$status_id") else
echo 'Input id'
read status_id
reply_status=$(status_api_one "$status_id")
fi
if [ "$quoting_reply" = 'true' ]; then if [ "$quoting_reply" = 'true' ]; then
echo "$reply_status" | jj content | html_to_txt_render | sed 's/^/> /' > tmp_status.md echo "$reply_status" | jj content | html_to_txt_render | sed 's/^/> /' > tmp_status.md
fi fi
if [ "$copy_mentions" = 'true' ]; then if [ "$copy_mentions" = 'true' ]; then
mentions_reply=$(echo "$reply_status" | jj -l 'mentions.#.acct' | delq | legacy_addr_preprocess | tr '\n' ',' | sed 's/,$//g') mentions_reply=$(echo "$reply_status" | jj -l 'mentions.#.acct' | delq | legacy_addr_preprocess | tr '\n' ',' | sed 's/,$//g')
fi fi
write_status_menu "$status_id" write_status_menu "$(echo "$reply_status" | jj id)"
} }
share_and_favorite_mode() share_and_favorite_mode()
{ {
echo 'Input id (s - stop)' if [ -n "$1" ]; then
shareandfavmode=1 share_api_status "$1"
while [ $shareandfavmode -eq 1 ]; do echo "$http_code"
read status_id favorite_api_status "$1"
if [ "$status_id" = 's' ]; then echo "$http_code"
shareandfavmode=0 else
else echo 'Input id (s - stop)'
share_api_status "$status_id" shareandfavmode=1
echo "$http_code" while [ $shareandfavmode -eq 1 ]; do
favorite_api_status "$status_id" read status_id
echo "$http_code" if [ "$status_id" = 's' ]; then
fi shareandfavmode=0
done else
share_api_status "$status_id"
echo "$http_code"
favorite_api_status "$status_id"
echo "$http_code"
fi
done
fi
} }
share_api_status() share_api_status()