Welcome to mirror list, hosted at ThFree Co, Russian Federation.

image_repository.js « static_site_editor « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4ad2e2618acca0fa4a5b944961ca553bf2f6c379 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import createFlash from '~/flash';
import { __ } from '~/locale';
import { getBinary } from './services/image_service';

const imageRepository = () => {
  const images = new Map();
  const flash = (message) =>
    createFlash({
      message,
    });

  const add = (file, url) => {
    getBinary(file)
      .then((content) => images.set(url, content))
      .catch(() => flash(__('Something went wrong while inserting your image. Please try again.')));
  };

  const get = (path) => images.get(path);

  const getAll = () => images;

  return { add, get, getAll };
};

export default imageRepository;