Skip to content

Commit

Permalink
feat: remove duplicate of OfflinePackStatus type (#542)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Replace OfflineProgressStatus with OfflinePackStatus
  • Loading branch information
KiwiKilian authored Dec 8, 2024
1 parent b342f1b commit 9e231b7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 28 deletions.
9 changes: 3 additions & 6 deletions packages/examples/src/examples/Map/CreateOfflineRegion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import geoViewport from "@mapbox/geo-viewport";
import MapLibreGL, {
OfflinePack,
type OfflinePackError,
type OfflineProgressStatus,
type OfflinePackStatus,
} from "@maplibre/maplibre-react-native";
import { useEffect, useState } from "react";
import {
Expand Down Expand Up @@ -69,7 +69,7 @@ function getRegionDownloadState(downloadState: OfflinePackDownloadState) {

export default function CreateOfflineRegion() {
const [offlineRegionStatus, setOfflineRegionStatus] =
useState<OfflineProgressStatus | null>(null);
useState<OfflinePackStatus | null>(null);
const [offlinePack, setOfflinePack] = useState<OfflinePack | null>(null);
const [isLoading, setIsLoading] = useState(true);

Expand All @@ -79,10 +79,7 @@ export default function CreateOfflineRegion() {
};
}, []);

function onDownloadProgress(
pack: OfflinePack,
status: OfflineProgressStatus,
) {
function onDownloadProgress(pack: OfflinePack, status: OfflinePackStatus) {
setOfflinePack(pack);
setOfflineRegionStatus(status);
}
Expand Down
5 changes: 1 addition & 4 deletions src/MapLibreRN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ export {
type Location,
} from "./modules/location/locationManager";
export { default as offlineManager } from "./modules/offline/offlineManager";
export type {
OfflineProgressStatus,
OfflinePackError,
} from "./modules/offline/offlineManager";
export type { OfflinePackError } from "./modules/offline/offlineManager";
export type { OfflinePackStatus } from "./modules/offline/OfflinePack";
export { default as OfflinePack } from "./modules/offline/OfflinePack";
export { default as OfflineCreatePackOptions } from "./modules/offline/OfflineCreatePackOptions";
Expand Down
2 changes: 1 addition & 1 deletion src/modules/offline/OfflinePack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export type OfflinePackStatus = {
percentage: number;
completedResourceCount: number;
completedResourceSize: number;
completedTileSize: number;
completedTileCount: number;
completedTileSize: number;
requiredResourceCount: number;
};

Expand Down
20 changes: 3 additions & 17 deletions src/modules/offline/offlineManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import OfflineCreatePackOptions, {
type OfflineCreatePackInputOptions,
} from "./OfflineCreatePackOptions";
import OfflinePack from "./OfflinePack";
import OfflinePack, { type OfflinePackStatus } from "./OfflinePack";
import { isUndefined, isFunction, isAndroid } from "../../utils";

const MapLibreRN = NativeModules.MLRNModule;
Expand All @@ -16,17 +16,6 @@ export const OfflineModuleEventEmitter = new NativeEventEmitter(
MLRNOfflineModule,
);

export type OfflineProgressStatus = {
name: string;
state: number;
percentage: number;
completedResourceSize: number;
completedTileCount: number;
completedResourceCount: number;
requiredResourceCount: number;
completedTileSize: number;
};

export type OfflinePackError = {
name: string;
message: string;
Expand All @@ -37,13 +26,10 @@ type ErrorEvent = {
};

type ProgressEvent = {
payload: OfflineProgressStatus;
payload: OfflinePackStatus;
};

type ProgressListener = (
pack: OfflinePack,
status: OfflineProgressStatus,
) => void;
type ProgressListener = (pack: OfflinePack, status: OfflinePackStatus) => void;
type ErrorListener = (pack: OfflinePack, err: OfflinePackError) => void;

/**
Expand Down

0 comments on commit 9e231b7

Please sign in to comment.