Commit 41ce194c authored by Martin Santangelo's avatar Martin Santangelo
Browse files

(feat) remember hastag on/off value

parent afcf26d5
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -4,6 +4,7 @@ import {
} from 'mobx';
} from 'mobx';


import hashtagService from '../services/hashtag.service'
import hashtagService from '../services/hashtag.service'
import settingsStore from '../../settings/SettingsStore';


/**
/**
 * Hashtag
 * Hashtag
@@ -36,6 +37,7 @@ class HashtagStore {
  @action
  @action
  toggleAll() {
  toggleAll() {
    this.all = !this.all;
    this.all = !this.all;
    settingsStore.setUseHashtags(!this.all);
  }
  }


  /**
  /**
@@ -44,6 +46,7 @@ class HashtagStore {
  @action
  @action
  setAll(value) {
  setAll(value) {
    this.all = value;
    this.all = value;
    settingsStore.setUseHashtags(!this.all);
  }
  }


  /**
  /**
+1 −0
Original line number Original line Diff line number Diff line
@@ -30,6 +30,7 @@ import testID from '../common/helpers/testID';


import { GOOGLE_PLAY_STORE } from '../config/Config';
import { GOOGLE_PLAY_STORE } from '../config/Config';
import i18n from '../common/services/i18n.service';
import i18n from '../common/services/i18n.service';
import settingsStore from '../settings/SettingsStore';


/**
/**
 * Newsfeed filters
 * Newsfeed filters
+13 −1
Original line number Original line Diff line number Diff line
@@ -2,6 +2,7 @@ import { observable, action } from 'mobx'


import logService from '../common/services/log.service';
import logService from '../common/services/log.service';
import storageService from '../common/services/storage.service';
import storageService from '../common/services/storage.service';
import appStore from '../../AppStores';


/**
/**
 * Store for the values held in Settings.
 * Store for the values held in Settings.
@@ -13,6 +14,7 @@ class SettingsStore {


  consumerNsfw = [];
  consumerNsfw = [];
  creatorNsfw = [];
  creatorNsfw = [];
  useHashtag = true;


  /**
  /**
   * Initializes local variables with their correct values as stored locally.
   * Initializes local variables with their correct values as stored locally.
@@ -20,12 +22,17 @@ class SettingsStore {
   */
   */
  @action.bound
  @action.bound
  async init() {
  async init() {
    const data  = await storageService.multiGet(['LeftHanded', 'AppLog', 'CreatorNsfw', 'ConsumerNsfw']);
    const data  = await storageService.multiGet(['LeftHanded', 'AppLog', 'CreatorNsfw', 'ConsumerNsfw', 'UseHashtags']);
    if (!data) return;
    if (!data) return;
    this.leftHanded = data[0][1];
    this.leftHanded = data[0][1];
    this.appLog = data[1][1];
    this.appLog = data[1][1];
    this.creatorNsfw = data[2][1] || [];
    this.creatorNsfw = data[2][1] || [];
    this.consumerNsfw = data[3][1] || [];
    this.consumerNsfw = data[3][1] || [];
    this.useHashtags = data[4][1] === null ? true : data[4][1];

    // set the initial value for hashtag
    appStore.hashtag.setAll(!this.useHashtags);

    return this;
    return this;
  }
  }


@@ -57,5 +64,10 @@ class SettingsStore {
    this.consumerNsfw = value;
    this.consumerNsfw = value;
  }
  }


  setUseHashtags(value) {
    storageService.setItem('UseHashtags', value);
    this.useHashtags = value;
  }

}
}
export default new SettingsStore;
export default new SettingsStore;