debian-mirror-gitlab/app/assets/javascripts/static_site_editor/image_repository.js

21 lines
553 B
JavaScript
Raw Normal View History

2020-07-28 23:09:34 +05:30
import { __ } from '~/locale';
2020-10-24 23:57:45 +05:30
import { deprecatedCreateFlash as Flash } from '~/flash';
2020-07-28 23:09:34 +05:30
import { getBinary } from './services/image_service';
const imageRepository = () => {
const images = new Map();
const flash = message => new Flash(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 getAll = () => images;
return { add, getAll };
};
export default imageRepository;