Update: Temporary fix for bug

This commit is contained in:
speediegq 2022-09-22 17:59:07 +02:00
parent cfd0ba0172
commit b96ec6579b

29
iron
View file

@ -15,6 +15,7 @@ IRON_EXIT()
$WDIR/iron-messagedata \
$WDIR/iron-message \
$WDIR/iron-api \
$WDIR/iron-api-orig
clear
echo $ENDMSG
exit 0
@ -27,6 +28,7 @@ IRON_MAIN()
$WDIR/iron-editor-message \
$WDIR/iron-messagedata \
$WDIR/iron-api \
$WDIR/iron-api-orig
clear
${0}
IRON_EXIT
@ -130,8 +132,13 @@ IRON_FAIL_NOT_CONNECTED() {
IRON_DOWNLOAD_API()
{
# download everything from the api
curl -so $WDIR/iron-api $INSTANCE/api.php
sed -i "s|\n|${COLOR_01}\n|g" $WDIR/iron-api
curl -so $WDIR/iron-api-orig $INSTANCE/api.php
if [ -e "$WDIR/iron-api-orig" ]; then
sed "s|\n|${COLOR_01}\n|g" $WDIR/iron-api-orig > $WDIR/iron-api
else
IRON_DOWNLOAD_API
fi
}
@ -212,18 +219,18 @@ IRON_PRINT_MESSAGES()
{
# fail if the json is not valid
FAIL_COULD_NOT_PARSE() {
rm -f $WDIR/iron-messagedata
rm -f $WDIR/iron-session
# originally wanted to fail the client completely if the json isn't valid
# there is currently some weird bug though so for now we'll restart it to hide the problem
clear
printf "Error: Could not parse JSON. Check with your instance maintainer that it is valid.\n"
printf "Error code: 1\n"
exit 1
rm -f $WDIR/iron-messagedata $WDIR/iron-message
$0 && IRON_EXIT
}
rm -f $WDIR/iron-editor-message \
$WDIR/iron-messagedata \
$WDIR/iron-message \
$WDIR/iron-api
$WDIR/iron-api \
$WDIR/iron-api-orig
IRON_DOWNLOAD_API
@ -300,7 +307,7 @@ IRON_CHECK_UPDATE()
{
if [ -e "$WDIR/iron-messages" ]; then
case "$(cat $WDIR/iron-messages | head -n 1 | sed 's/"//g')" in
"$(head -n 2 $WDIR/iron-messagedata | tail -n 1)") IRON_PRINT_MESSAGES ;;
"$(head -n 2 $WDIR/iron-messagedata | tail -n 1)") IRON_CHECK_MODE ;;
esac
if [ "$SEPCOUNT" = "$(tput cols)" ]; then
@ -368,7 +375,7 @@ IRON_CHECK_MODE()
read -t 1 -n 1 MODE > /dev/null
case "$MODE" in
"i") MODE="INSERT" && IRON_INSERT ;;
"") MODE="NORMAL" ;;
"") MODE="NORMAL" ; IRON_CHECK_UPDATE ;;
"r") rm -f $WDIR/iron-messagedata $WDIR/iron-message && $0 && IRON_EXIT ;;
":") IRON_CMD ;;
"e") touch $WDIR/iron-editor-message ; $EDITOR $WDIR/iron-editor-message && IRON_MESSAGE_TYPE=editor && IRON_SEND_MESSAGE ;;
@ -377,8 +384,6 @@ IRON_CHECK_MODE()
"l") IRON_MAIN ;;
esac
IRON_DOWNLOAD_API
IRON_CHECK_MODE # loop it
}