Save latest message to localstorage

use stored data for initial value and time
refactor