Refactoring: remove obsolete 'Loc'-interface
This commit is contained in:
parent
12eb2a2d55
commit
4606df7d2b
5 changed files with 8 additions and 42 deletions
|
@ -1,7 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {OsmConnection} from "../../Logic/Osm/OsmConnection"
|
import {OsmConnection} from "../../Logic/Osm/OsmConnection"
|
||||||
import {UIEventSource} from "../../Logic/UIEventSource"
|
import {UIEventSource} from "../../Logic/UIEventSource"
|
||||||
import type Loc from "../../Models/Loc"
|
|
||||||
import * as themeOverview from "../../assets/generated/theme_overview.json"
|
import * as themeOverview from "../../assets/generated/theme_overview.json"
|
||||||
import {Utils} from "../../Utils"
|
import {Utils} from "../../Utils"
|
||||||
import ThemesList from "./ThemesList.svelte"
|
import ThemesList from "./ThemesList.svelte"
|
||||||
|
@ -10,7 +9,7 @@
|
||||||
import LoginToggle from "../Base/LoginToggle.svelte";
|
import LoginToggle from "../Base/LoginToggle.svelte";
|
||||||
|
|
||||||
export let search: UIEventSource<string>
|
export let search: UIEventSource<string>
|
||||||
export let state: { osmConnection: OsmConnection; locationControl?: UIEventSource<Loc> }
|
export let state: { osmConnection: OsmConnection }
|
||||||
export let onMainScreen: boolean = true
|
export let onMainScreen: boolean = true
|
||||||
|
|
||||||
const prefix = "mapcomplete-hidden-theme-"
|
const prefix = "mapcomplete-hidden-theme-"
|
||||||
|
|
|
@ -2,8 +2,7 @@ import Svg from "../../Svg"
|
||||||
import Combine from "../Base/Combine"
|
import Combine from "../Base/Combine"
|
||||||
import Translations from "../i18n/Translations"
|
import Translations from "../i18n/Translations"
|
||||||
import LayoutConfig, {LayoutInformation} from "../../Models/ThemeConfig/LayoutConfig"
|
import LayoutConfig, {LayoutInformation} from "../../Models/ThemeConfig/LayoutConfig"
|
||||||
import {ImmutableStore, Store, UIEventSource} from "../../Logic/UIEventSource"
|
import {ImmutableStore, Store} from "../../Logic/UIEventSource"
|
||||||
import Loc from "../../Models/Loc"
|
|
||||||
import UserRelatedState from "../../Logic/State/UserRelatedState"
|
import UserRelatedState from "../../Logic/State/UserRelatedState"
|
||||||
import {Utils} from "../../Utils"
|
import {Utils} from "../../Utils"
|
||||||
import themeOverview from "../../assets/generated/theme_overview.json"
|
import themeOverview from "../../assets/generated/theme_overview.json"
|
||||||
|
@ -19,7 +18,6 @@ export default class MoreScreen extends Combine {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
state: UserRelatedState & {
|
state: UserRelatedState & {
|
||||||
locationControl?: UIEventSource<Loc>
|
|
||||||
layoutToUse?: LayoutConfig
|
layoutToUse?: LayoutConfig
|
||||||
},
|
},
|
||||||
onMainScreen: boolean = false
|
onMainScreen: boolean = false
|
||||||
|
@ -141,7 +139,7 @@ export default class MoreScreen extends Combine {
|
||||||
private static createUrlFor(
|
private static createUrlFor(
|
||||||
layout: { id: string; definition?: string },
|
layout: { id: string; definition?: string },
|
||||||
isCustom: boolean,
|
isCustom: boolean,
|
||||||
state?: { locationControl?: UIEventSource<{ lat; lon; zoom }>; layoutToUse?: { id } }
|
state?: { layoutToUse?: { id } }
|
||||||
): Store<string> {
|
): Store<string> {
|
||||||
if (layout === undefined) {
|
if (layout === undefined) {
|
||||||
return undefined
|
return undefined
|
||||||
|
@ -155,8 +153,6 @@ export default class MoreScreen extends Combine {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentLocation = state?.locationControl
|
|
||||||
|
|
||||||
let path = window.location.pathname
|
let path = window.location.pathname
|
||||||
// Path starts with a '/' and contains everything, e.g. '/dir/dir/page.html'
|
// Path starts with a '/' and contains everything, e.g. '/dir/dir/page.html'
|
||||||
path = path.substr(0, path.lastIndexOf("/"))
|
path = path.substr(0, path.lastIndexOf("/"))
|
||||||
|
@ -179,18 +175,6 @@ export default class MoreScreen extends Combine {
|
||||||
hash = "#" + btoa(JSON.stringify(layout.definition))
|
hash = "#" + btoa(JSON.stringify(layout.definition))
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return new ImmutableStore<string>(`${linkPrefix}${hash}`)
|
||||||
currentLocation?.map((currentLocation) => {
|
|
||||||
const params = [
|
|
||||||
["z", currentLocation?.zoom],
|
|
||||||
["lat", currentLocation?.lat],
|
|
||||||
["lon", currentLocation?.lon],
|
|
||||||
]
|
|
||||||
.filter((part) => part[1] !== undefined)
|
|
||||||
.map((part) => part[0] + "=" + part[1])
|
|
||||||
.join("&")
|
|
||||||
return `${linkPrefix}${params}${hash}`
|
|
||||||
}) ?? new ImmutableStore<string>(`${linkPrefix}`)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
import {ImmutableStore, Store, UIEventSource} from "../../Logic/UIEventSource"
|
import {ImmutableStore, Store, UIEventSource} from "../../Logic/UIEventSource"
|
||||||
import UserDetails, {OsmConnection} from "../../Logic/Osm/OsmConnection"
|
import UserDetails, {OsmConnection} from "../../Logic/Osm/OsmConnection"
|
||||||
import Constants from "../../Models/Constants"
|
import Constants from "../../Models/Constants"
|
||||||
import type Loc from "../../Models/Loc"
|
|
||||||
import type {LayoutInformation} from "../../Models/ThemeConfig/LayoutConfig"
|
import type {LayoutInformation} from "../../Models/ThemeConfig/LayoutConfig"
|
||||||
import Tr from "../Base/Tr.svelte"
|
import Tr from "../Base/Tr.svelte"
|
||||||
import SubtleLink from "../Base/SubtleLink.svelte";
|
import SubtleLink from "../Base/SubtleLink.svelte";
|
||||||
|
@ -12,7 +11,7 @@
|
||||||
export let theme: LayoutInformation
|
export let theme: LayoutInformation
|
||||||
export let isCustom: boolean = false
|
export let isCustom: boolean = false
|
||||||
export let userDetails: UIEventSource<UserDetails>
|
export let userDetails: UIEventSource<UserDetails>
|
||||||
export let state: { osmConnection: OsmConnection; locationControl?: UIEventSource<Loc> }
|
export let state: { layoutToUse: {id: string}, osmConnection: OsmConnection }
|
||||||
|
|
||||||
$: title = new Translation(
|
$: title = new Translation(
|
||||||
theme.title,
|
theme.title,
|
||||||
|
@ -24,7 +23,7 @@
|
||||||
function createUrl(
|
function createUrl(
|
||||||
layout: { id: string; definition?: string },
|
layout: { id: string; definition?: string },
|
||||||
isCustom: boolean,
|
isCustom: boolean,
|
||||||
state?: { locationControl?: UIEventSource<{ lat; lon; zoom }>; layoutToUse?: { id } }
|
state?: { layoutToUse?: { id } }
|
||||||
): Store<string> {
|
): Store<string> {
|
||||||
if (layout === undefined) {
|
if (layout === undefined) {
|
||||||
return undefined
|
return undefined
|
||||||
|
@ -38,7 +37,6 @@
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentLocation = state?.locationControl
|
|
||||||
|
|
||||||
let path = window.location.pathname
|
let path = window.location.pathname
|
||||||
// Path starts with a '/' and contains everything, e.g. '/dir/dir/page.html'
|
// Path starts with a '/' and contains everything, e.g. '/dir/dir/page.html'
|
||||||
|
@ -63,19 +61,7 @@
|
||||||
hash = "#" + btoa(JSON.stringify(layout.definition))
|
hash = "#" + btoa(JSON.stringify(layout.definition))
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return new ImmutableStore<string>(`${linkPrefix}${hash}`)
|
||||||
currentLocation?.map((currentLocation) => {
|
|
||||||
const params = [
|
|
||||||
["z", currentLocation?.zoom],
|
|
||||||
["lat", currentLocation?.lat],
|
|
||||||
["lon", currentLocation?.lon],
|
|
||||||
]
|
|
||||||
.filter((part) => part[1] !== undefined)
|
|
||||||
.map((part) => part[0] + "=" + part[1])
|
|
||||||
.join("&")
|
|
||||||
return `${linkPrefix}${params}${hash}`
|
|
||||||
}) ?? new ImmutableStore<string>(`${linkPrefix}`)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let href = createUrl(theme, isCustom, state)
|
let href = createUrl(theme, isCustom, state)
|
||||||
|
|
|
@ -3,14 +3,13 @@
|
||||||
|
|
||||||
import {OsmConnection} from "../../Logic/Osm/OsmConnection"
|
import {OsmConnection} from "../../Logic/Osm/OsmConnection"
|
||||||
import {UIEventSource} from "../../Logic/UIEventSource"
|
import {UIEventSource} from "../../Logic/UIEventSource"
|
||||||
import type Loc from "../../Models/Loc"
|
|
||||||
import ThemeButton from "./ThemeButton.svelte"
|
import ThemeButton from "./ThemeButton.svelte"
|
||||||
import {LayoutInformation} from "../../Models/ThemeConfig/LayoutConfig"
|
import {LayoutInformation} from "../../Models/ThemeConfig/LayoutConfig"
|
||||||
import MoreScreen from "./MoreScreen"
|
import MoreScreen from "./MoreScreen"
|
||||||
|
|
||||||
export let search: UIEventSource<string>
|
export let search: UIEventSource<string>
|
||||||
export let themes: LayoutInformation[]
|
export let themes: LayoutInformation[]
|
||||||
export let state: { osmConnection: OsmConnection; locationControl?: UIEventSource<Loc> }
|
export let state: { osmConnection: OsmConnection }
|
||||||
export let isCustom: boolean = false
|
export let isCustom: boolean = false
|
||||||
export let onMainScreen: boolean = true
|
export let onMainScreen: boolean = true
|
||||||
export let hideThemes: boolean = true
|
export let hideThemes: boolean = true
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {OsmConnection} from "../../Logic/Osm/OsmConnection"
|
import {OsmConnection} from "../../Logic/Osm/OsmConnection"
|
||||||
import {Store, Stores, UIEventSource} from "../../Logic/UIEventSource"
|
import {Store, Stores, UIEventSource} from "../../Logic/UIEventSource"
|
||||||
import type Loc from "../../Models/Loc"
|
|
||||||
import {Utils} from "../../Utils"
|
import {Utils} from "../../Utils"
|
||||||
import ThemesList from "./ThemesList.svelte"
|
import ThemesList from "./ThemesList.svelte"
|
||||||
import Translations from "../i18n/Translations"
|
import Translations from "../i18n/Translations"
|
||||||
|
@ -10,7 +9,6 @@
|
||||||
export let search: UIEventSource<string>
|
export let search: UIEventSource<string>
|
||||||
export let state: UserRelatedState & {
|
export let state: UserRelatedState & {
|
||||||
osmConnection: OsmConnection
|
osmConnection: OsmConnection
|
||||||
locationControl?: UIEventSource<Loc>
|
|
||||||
}
|
}
|
||||||
export let onMainScreen: boolean = true
|
export let onMainScreen: boolean = true
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue