/*
Copyright 2015, 2016 OpenMarket Ltd
Copyright 2017 Vector Creations Ltd
Copyright 2018 New Vector Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
"use strict";

var _bluebird = require("bluebird");

var _bluebird2 = _interopRequireDefault(_bluebird);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
 * This is an internal module.
 * @module store/stub
 */

/**
 * Construct a stub store. This does no-ops on most store methods.
 * @constructor
 */
function StubStore() {
  this.fromToken = null;
}

StubStore.prototype = {

  /**
   * Get the sync token.
   * @return {string}
   */
  getSyncToken: function getSyncToken() {
    return this.fromToken;
  },

  /**
   * Set the sync token.
   * @param {string} token
   */
  setSyncToken: function setSyncToken(token) {
    this.fromToken = token;
  },

  /**
   * No-op.
   * @param {Group} group
   */
  storeGroup: function storeGroup(group) {},

  /**
   * No-op.
   * @param {string} groupId
   * @return {null}
   */
  getGroup: function getGroup(groupId) {
    return null;
  },

  /**
   * No-op.
   * @return {Array} An empty array.
   */
  getGroups: function getGroups() {
    return [];
  },

  /**
   * No-op.
   * @param {Room} room
   */
  storeRoom: function storeRoom(room) {},

  /**
   * No-op.
   * @param {string} roomId
   * @return {null}
   */
  getRoom: function getRoom(roomId) {
    return null;
  },

  /**
   * No-op.
   * @return {Array} An empty array.
   */
  getRooms: function getRooms() {
    return [];
  },

  /**
   * Permanently delete a room.
   * @param {string} roomId
   */
  removeRoom: function removeRoom(roomId) {
    return;
  },

  /**
   * No-op.
   * @return {Array} An empty array.
   */
  getRoomSummaries: function getRoomSummaries() {
    return [];
  },

  /**
   * No-op.
   * @param {User} user
   */
  storeUser: function storeUser(user) {},

  /**
   * No-op.
   * @param {string} userId
   * @return {null}
   */
  getUser: function getUser(userId) {
    return null;
  },

  /**
   * No-op.
   * @return {User[]}
   */
  getUsers: function getUsers() {
    return [];
  },

  /**
   * No-op.
   * @param {Room} room
   * @param {integer} limit
   * @return {Array}
   */
  scrollback: function scrollback(room, limit) {
    return [];
  },

  /**
   * Store events for a room.
   * @param {Room} room The room to store events for.
   * @param {Array<MatrixEvent>} events The events to store.
   * @param {string} token The token associated with these events.
   * @param {boolean} toStart True if these are paginated results.
   */
  storeEvents: function storeEvents(room, events, token, toStart) {},

  /**
   * Store a filter.
   * @param {Filter} filter
   */
  storeFilter: function storeFilter(filter) {},

  /**
   * Retrieve a filter.
   * @param {string} userId
   * @param {string} filterId
   * @return {?Filter} A filter or null.
   */
  getFilter: function getFilter(userId, filterId) {
    return null;
  },

  /**
   * Retrieve a filter ID with the given name.
   * @param {string} filterName The filter name.
   * @return {?string} The filter ID or null.
   */
  getFilterIdByName: function getFilterIdByName(filterName) {
    return null;
  },

  /**
   * Set a filter name to ID mapping.
   * @param {string} filterName
   * @param {string} filterId
   */
  setFilterIdByName: function setFilterIdByName(filterName, filterId) {},

  /**
   * Store user-scoped account data events
   * @param {Array<MatrixEvent>} events The events to store.
   */
  storeAccountDataEvents: function storeAccountDataEvents(events) {},

  /**
   * Get account data event by event type
   * @param {string} eventType The event type being queried
   */
  getAccountData: function getAccountData(eventType) {},

  /**
   * setSyncData does nothing as there is no backing data store.
   *
   * @param {Object} syncData The sync data
   * @return {Promise} An immediately resolved promise.
   */
  setSyncData: function setSyncData(syncData) {
    return _bluebird2.default.resolve();
  },

  /**
   * We never want to save becase we have nothing to save to.
   *
   * @return {boolean} If the store wants to save
   */
  wantsSave: function wantsSave() {
    return false;
  },

  /**
   * Save does nothing as there is no backing data store.
   */
  save: function save() {},

  /**
   * Startup does nothing.
   * @return {Promise} An immediately resolved promise.
   */
  startup: function startup() {
    return _bluebird2.default.resolve();
  },

  /**
   * @return {Promise} Resolves with a sync response to restore the
   * client state to where it was at the last save, or null if there
   * is no saved sync data.
   */
  getSavedSync: function getSavedSync() {
    return _bluebird2.default.resolve(null);
  },

  /**
   * @return {Promise} If there is a saved sync, the nextBatch token
   * for this sync, otherwise null.
   */
  getSavedSyncToken: function getSavedSyncToken() {
    return _bluebird2.default.resolve(null);
  },

  /**
   * Delete all data from this store. Does nothing since this store
   * doesn't store anything.
   * @return {Promise} An immediately resolved promise.
   */
  deleteAllData: function deleteAllData() {
    return _bluebird2.default.resolve();
  },

  getOutOfBandMembers: function getOutOfBandMembers() {
    return _bluebird2.default.resolve(null);
  },

  setOutOfBandMembers: function setOutOfBandMembers() {
    return _bluebird2.default.resolve();
  }
};

/** Stub Store class. */
module.exports = StubStore;
//# sourceMappingURL=stub.js.map