diff --git a/src/App.native.tsx b/src/App.native.tsx index 17b8b455..8bb20492 100644 --- a/src/App.native.tsx +++ b/src/App.native.tsx @@ -28,6 +28,7 @@ const App = observer(() => { analytics.init(store) notifee.init(store) SplashScreen.hide() + store.hackCheckIfUpgradeNeeded() Linking.getInitialURL().then((url: string | null) => { if (url) { store.nav.handleLink(url) diff --git a/src/lib/analytics.tsx b/src/lib/analytics.tsx index 091a7a1e..5358a868 100644 --- a/src/lib/analytics.tsx +++ b/src/lib/analytics.tsx @@ -7,7 +7,7 @@ const segmentClient = createClient({ writeKey: '8I6DsgfiSLuoONyaunGoiQM7A6y2ybdI', trackAppLifecycleEvents: false, }) -export const track = segmentClient.track.bind(segmentClient) +export const track = segmentClient?.track?.bind?.(segmentClient) export {useAnalytics} from '@segment/analytics-react-native' diff --git a/src/state/models/root-store.ts b/src/state/models/root-store.ts index 229c7b3c..d60df7dd 100644 --- a/src/state/models/root-store.ts +++ b/src/state/models/root-store.ts @@ -2,7 +2,7 @@ * The root store is the base of all modeled state. */ -import {makeAutoObservable} from 'mobx' +import {makeAutoObservable, runInAction} from 'mobx' import {AtpAgent} from '@atproto/api' import {createContext, useContext} from 'react' import {DeviceEventEmitter, EmitterSubscription} from 'react-native' @@ -39,6 +39,23 @@ export class RootStoreModel { profiles = new ProfilesViewModel(this) linkMetas = new LinkMetasViewModel(this) + // HACK + // this flag is to track the lexicon breaking refactor + // it should be removed once we get that done + // -prf + hackUpgradeNeeded = false + async hackCheckIfUpgradeNeeded() { + try { + const res = await fetch('https://bsky.social/xrpc/app.bsky.feed.getLikes') + await res.text() + runInAction(() => { + this.hackUpgradeNeeded = res.status !== 501 + }) + } catch (e) { + this.log.error('Failed to hackCheckIfUpgradeNeeded', {e}) + } + } + constructor(agent: AtpAgent) { this.agent = agent makeAutoObservable(this, { diff --git a/src/view/shell/mobile/index.tsx b/src/view/shell/mobile/index.tsx index da8e73a6..6caf8923 100644 --- a/src/view/shell/mobile/index.tsx +++ b/src/view/shell/mobile/index.tsx @@ -362,6 +362,39 @@ export const MobileShell: React.FC = observer(() => { // transform: [{scale: newTabInterp}], // } + if (store.hackUpgradeNeeded) { + return ( + + + + + + Update required + + + Please update your app to the latest version. If no update is + available yet, please check the App Store in a day or so. + + + What's happening? + + + We're in the final stages of the AT Protocol's v1 development. To + make sure everything works as well as possible, we're making final + breaking changes to the APIs. + + + If we didn't botch this process, a new version of the app should + be available now. + + + + + + + ) + } + if (!store.session.hasSession) { return ( diff --git a/tsconfig.json b/tsconfig.json index 62c9f2ca..f1e7f443 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,4 +9,4 @@ "view/*": ["./src/view/*"] } } -} \ No newline at end of file +}