Section One BBS

Welcome, Guest.


Subject: Javascript weirdness Date: Fri Apr 22 2022 10:21 pm
From: deon To: Digital Man

  Re: Javascript weirdness
  By: deon to Digital Man on Fri Apr 22 2022 10:00 pm

 >  >  > Originally I was iterating through through that result to update the me
ssages, but I was noticing the following behaviour:
 >
 >  >  > * call get_all_msg_headers()
 >  >  > * iterate through each item "for (hdr in hdrs)"
 >  >  > * set hdr.tag to "foo"
 >  >  > * pass hdr to put_msg_header();
 >
 >  >  > But the items were not updating.
 >
 >  > Does put_msg_header() return false when you try to use it in that manner?
 >
 > So I cant reproduce this now. I'll revert my code to use get_all_msg_headers 
and if I can reproduce it, I'll provide a log and the
 > status returned.

OK, I got it. It seems to depend on whether I work with the object vs the attrib
ute of it.

First run, where I echo the object "after" put_msg_header:

for (var X in msgs)

X:35
ORIG:0353 <-- msgs[x]
CHANGE:0425 <-- msgs[x].tags = '0425'
<put_msg_header>
<JSON.stringify(msgs[x])>
object:{"tags":"0425","number":38,"to":"deon","subject":"Test Reply","from":"Cle
aring ...
STATUS:0 <!-- return from put_msg_header
AFTER:0425 <-- msgs[x]

vs echo the object "before" put_msg_header:

X:35
ORIG:0353 <!-- msgs[x]
CHANGE:0389 <!-- msgs[x] = '0389'
<JSON.stringify(msgs[x])> (Note it has reverted)
object:{"tags":"0353","number":38,"offset":0,"to":"deon","from":"Clearing Houz",
"subject":"Test ...
<put_msg_header>
STATUS:0 <!-- result
AFTER:0353 <!-- no change

So it seems JSON.stringifying the object reverts its value, that doesnt seem rig
ht, but as long as I dont do that I guess I'm OK.


...δεσ∩

---
 ■ Synchronet ■ Alterant | an SBBS in Docker on Pi!

Previous Message       Next Message
In Reply To: Javascript weirdness (deon)