You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1.3 KiB

  1. const element = document.getElementById('initial-state');
  2. const initialState = element && function () {
  3. const result = JSON.parse(element.textContent);
  4. try {
  5. result.local_settings = JSON.parse(localStorage.getItem('mastodon-settings'));
  6. } catch (e) {
  7. result.local_settings = {};
  8. }
  9. return result;
  10. }();
  11. const getMeta = (prop) => initialState && initialState.meta && initialState.meta[prop];
  12. export const reduceMotion = getMeta('reduce_motion');
  13. export const autoPlayGif = getMeta('auto_play_gif');
  14. export const displaySensitiveMedia = getMeta('display_sensitive_media');
  15. export const displayMedia = getMeta('display_media') || (getMeta('display_sensitive_media') ? 'show_all' : 'default');
  16. export const unfollowModal = getMeta('unfollow_modal');
  17. export const boostModal = getMeta('boost_modal');
  18. export const favouriteModal = getMeta('favourite_modal');
  19. export const deleteModal = getMeta('delete_modal');
  20. export const me = getMeta('me');
  21. export const searchEnabled = getMeta('search_enabled');
  22. export const maxChars = (initialState && initialState.max_toot_chars) || 500;
  23. export const invitesEnabled = getMeta('invites_enabled');
  24. export const version = getMeta('version');
  25. export const mascot = getMeta('mascot');
  26. export const isStaff = getMeta('is_staff');
  27. export default initialState;