/**
 * Web platform settings using localStorage.
 * Returns Promises to match the Electron IPC-based API contract.
 */
const PREFIX = 'discord-clone-settings:';

export default {
  get(key) {
    try {
      const raw = localStorage.getItem(PREFIX + key);
      return Promise.resolve(raw !== null ? JSON.parse(raw) : undefined);
    } catch {
      return Promise.resolve(undefined);
    }
  },

  set(key, value) {
    try {
      localStorage.setItem(PREFIX + key, JSON.stringify(value));
      return Promise.resolve();
    } catch {
      return Promise.resolve();
    }
  },
};
