2020-03-25 12:51:26 +00:00
|
|
|
import { computed } from '@ember/object';
|
2018-02-08 23:06:10 +00:00
|
|
|
import { readOnly } from '@ember/object/computed';
|
2019-03-26 04:55:06 +00:00
|
|
|
import { copy } from 'ember-copy';
|
2018-02-08 23:06:10 +00:00
|
|
|
import Service from '@ember/service';
|
|
|
|
|
2018-02-17 02:59:40 +00:00
|
|
|
let list = {};
|
2018-02-08 23:06:10 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
export default class WatchListService extends Service {
|
|
|
|
@computed
|
|
|
|
get _list() {
|
2020-06-09 21:03:28 +00:00
|
|
|
return copy(list, true);
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2020-03-25 12:51:26 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@readOnly('_list') list;
|
2018-02-08 23:06:10 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
constructor() {
|
|
|
|
super(...arguments);
|
2018-02-17 02:59:40 +00:00
|
|
|
list = {};
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2018-02-17 02:59:40 +00:00
|
|
|
|
2018-02-08 23:06:10 +00:00
|
|
|
getIndexFor(url) {
|
2018-03-21 20:28:56 +00:00
|
|
|
return list[url] || 1;
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2018-02-08 23:06:10 +00:00
|
|
|
|
|
|
|
setIndexFor(url, value) {
|
2018-08-21 20:47:01 +00:00
|
|
|
list[url] = +value;
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
|
|
|
}
|