blob: b7442fb5550f55c90af5907cdaead9fbc46ccdc0 (
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
import { asSettled } from "../utils/async-value";
import {
getSelectedLocation,
getFirstSourceActorForGeneratedSource,
} from "../selectors/sources";
export function getSourceTextContent(state, location) {
if (location.source.isOriginal) {
return state.sourcesContent.mutableOriginalSourceTextContentMapBySourceId.get(
location.source.id
);
}
let { sourceActor } = location;
if (!sourceActor) {
sourceActor = getFirstSourceActorForGeneratedSource(
state,
location.source.id
);
}
return state.sourcesContent.mutableGeneratedSourceTextContentMapBySourceActorId.get(
sourceActor.id
);
}
export function getSettledSourceTextContent(state, location) {
const content = getSourceTextContent(state, location);
return asSettled(content);
}
export function getSelectedSourceTextContent(state) {
const location = getSelectedLocation(state);
if (!location) {
return null;
}
return getSourceTextContent(state, location);
}
export function getSourcesEpoch(state) {
return state.sourcesContent.epoch;
}
|