Validate previous app version (#4151)
* Validate previous app version * Update snapshot and fix typo in constant
This commit is contained in:
parent
8b2d9a10f5
commit
4ad4b3b103
7 changed files with 93 additions and 15 deletions
|
|
@ -57,11 +57,10 @@ export default class FileAttachmentImage extends PureComponent {
|
|||
|
||||
const {file} = props;
|
||||
if (file && file.id) {
|
||||
const headers = {Authorization: `Bearer ${Client4.getToken()}`};
|
||||
const preloadImages = [{uri: Client4.getFileThumbnailUrl(file.id), headers}];
|
||||
const preloadImages = [{uri: Client4.getFileThumbnailUrl(file.id)}];
|
||||
|
||||
if (isGif(file)) {
|
||||
preloadImages.push({uri: Client4.getFileUrl(file.id), headers});
|
||||
preloadImages.push({uri: Client4.getFileUrl(file.id)});
|
||||
}
|
||||
|
||||
FastImage.preload(preloadImages);
|
||||
|
|
|
|||
|
|
@ -12,9 +12,6 @@ exports[`ProgressiveImage should match snapshot 1`] = `
|
|||
resizeMode="contain"
|
||||
source={
|
||||
Object {
|
||||
"headers": Object {
|
||||
"Authorization": "Bearer ",
|
||||
},
|
||||
"uri": "https://images.com/image.png",
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,10 +75,9 @@ export default class ProgressiveImage extends PureComponent {
|
|||
|
||||
load = () => {
|
||||
const {imageUri, thumbnailUri} = this.props;
|
||||
const headers = {Authorization: `Bearer ${Client4.getToken()}`};
|
||||
|
||||
if (thumbnailUri && imageUri) {
|
||||
FastImage.preload([{uri: imageUri, headers}]);
|
||||
FastImage.preload([{uri: imageUri}]);
|
||||
this.setThumbnail(thumbnailUri);
|
||||
} else if (imageUri) {
|
||||
this.setImage(imageUri);
|
||||
|
|
@ -184,11 +183,10 @@ export default class ProgressiveImage extends PureComponent {
|
|||
}
|
||||
|
||||
let source;
|
||||
const headers = {Authorization: `Bearer ${Client4.getToken()}`};
|
||||
if (hasPreview && !isImageReady) {
|
||||
source = {uri: thumb, headers};
|
||||
source = {uri: thumb};
|
||||
} else if (isImageReady) {
|
||||
source = {uri, headers};
|
||||
source = {uri};
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import store, {persistor} from 'app/store';
|
|||
import {waitForHydration} from 'app/store/utils';
|
||||
import EphemeralStore from 'app/store/ephemeral_store';
|
||||
import telemetry from 'app/telemetry';
|
||||
import {validatePreviousVersion} from 'app/utils/general';
|
||||
import pushNotificationsUtils from 'app/utils/push_notifications';
|
||||
|
||||
const init = async () => {
|
||||
|
|
@ -52,8 +53,10 @@ const launchApp = (credentials) => {
|
|||
|
||||
if (credentials) {
|
||||
waitForHydration(store, async () => {
|
||||
store.dispatch(loadMe());
|
||||
resetToChannel({skipMetrics: true});
|
||||
if (validatePreviousVersion(store, EphemeralStore.prevAppVersion)) {
|
||||
store.dispatch(loadMe());
|
||||
resetToChannel({skipMetrics: true});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
resetToSelectServer(emmProvider.allowOtherServers);
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@
|
|||
import {Platform} from 'react-native';
|
||||
import DeviceInfo from 'react-native-device-info';
|
||||
import {REHYDRATE} from 'redux-persist';
|
||||
import semver from 'semver/preload';
|
||||
|
||||
import {ViewTypes} from 'app/constants';
|
||||
import initialState from 'app/initial_state';
|
||||
import EphemeralStore from 'app/store/ephemeral_store';
|
||||
import {throttle} from 'app/utils/general';
|
||||
|
||||
import mattermostBucket from 'app/mattermost_bucket';
|
||||
|
|
@ -98,12 +100,18 @@ async function saveStateToFile(store) {
|
|||
function messageRetention(store) {
|
||||
return (next) => (action) => {
|
||||
if (action.type === REHYDRATE) {
|
||||
// On first run payload is not set (when installed)
|
||||
if (!action.payload) {
|
||||
// On first run payload is not set (when installed)
|
||||
const version = DeviceInfo.getVersion();
|
||||
const major = semver.major(version);
|
||||
const minor = semver.minor(version);
|
||||
const patch = semver.patch(version);
|
||||
const prevAppVersion = `${major}.${parseInt(minor, 10) - 1}.${patch}`;
|
||||
EphemeralStore.prevAppVersion = prevAppVersion;
|
||||
action.payload = {
|
||||
app: {
|
||||
build: DeviceInfo.getBuildNumber(),
|
||||
version: DeviceInfo.getVersion(),
|
||||
version,
|
||||
},
|
||||
views: {
|
||||
root: {
|
||||
|
|
@ -116,6 +124,10 @@ function messageRetention(store) {
|
|||
const {app} = action.payload;
|
||||
const {entities, views} = action.payload;
|
||||
|
||||
if (!EphemeralStore.prevAppVersion) {
|
||||
EphemeralStore.prevAppVersion = app?.version;
|
||||
}
|
||||
|
||||
if (!entities || !views) {
|
||||
return next(action);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@ import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
|
|||
|
||||
import {Posts} from '@mm-redux/constants';
|
||||
|
||||
import {logout} from 'app/actions/views/user';
|
||||
|
||||
const INVALID_VERSIONS = ['1.29.0'];
|
||||
|
||||
export function fromAutoResponder(post) {
|
||||
return Boolean(post.type && (post.type === Posts.SYSTEM_AUTO_RESPONDER));
|
||||
}
|
||||
|
|
@ -81,4 +85,13 @@ export function throttle(fn, limit, ...args) {
|
|||
|
||||
export function isPendingPost(postId, userId) {
|
||||
return postId.startsWith(userId);
|
||||
}
|
||||
|
||||
export function validatePreviousVersion(store, version) {
|
||||
if (INVALID_VERSIONS.includes(version)) {
|
||||
store.dispatch(logout());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
56
patches/react-native-fast-image+8.1.5.patch
Normal file
56
patches/react-native-fast-image+8.1.5.patch
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
diff --git a/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageCookieJar.java b/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageCookieJar.java
|
||||
new file mode 100644
|
||||
index 0000000..f2306f6
|
||||
--- /dev/null
|
||||
+++ b/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageCookieJar.java
|
||||
@@ -0,0 +1,38 @@
|
||||
+package com.dylanvann.fastimage;
|
||||
+
|
||||
+import android.webkit.CookieManager;
|
||||
+
|
||||
+import java.util.Collections;
|
||||
+import java.util.List;
|
||||
+
|
||||
+import okhttp3.Cookie;
|
||||
+import okhttp3.CookieJar;
|
||||
+import okhttp3.HttpUrl;
|
||||
+
|
||||
+public class FastImageCookieJar implements CookieJar {
|
||||
+ private CookieManager cookieManager;
|
||||
+
|
||||
+ private CookieManager getCookieManager() {
|
||||
+ if (cookieManager == null) {
|
||||
+ cookieManager = CookieManager.getInstance();
|
||||
+ }
|
||||
+
|
||||
+ return cookieManager;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void saveFromResponse(HttpUrl url, List<Cookie> cookies) {
|
||||
+ // Do nothing
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<Cookie> loadForRequest(HttpUrl url) {
|
||||
+ String cookie = getCookieManager().getCookie(url.toString());
|
||||
+
|
||||
+ if (cookie == null || cookie.isEmpty()) {
|
||||
+ return Collections.emptyList();
|
||||
+ }
|
||||
+
|
||||
+ return Collections.singletonList(Cookie.parse(url, cookie));
|
||||
+ }
|
||||
+}
|
||||
diff --git a/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageOkHttpProgressGlideModule.java b/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageOkHttpProgressGlideModule.java
|
||||
index 2214f04..bfb9895 100644
|
||||
--- a/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageOkHttpProgressGlideModule.java
|
||||
+++ b/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageOkHttpProgressGlideModule.java
|
||||
@@ -45,6 +45,7 @@ public class FastImageOkHttpProgressGlideModule extends LibraryGlideModule {
|
||||
OkHttpClient client = OkHttpClientProvider
|
||||
.getOkHttpClient()
|
||||
.newBuilder()
|
||||
+ .cookieJar(new FastImageCookieJar())
|
||||
.addInterceptor(createInterceptor(progressListener))
|
||||
.build();
|
||||
OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory(client);
|
||||
Loading…
Reference in a new issue