Skip to content

Commit

Permalink
🔀 Merge 0.27.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
nwingt committed May 3, 2022
2 parents b07f4e7 + 8d951c4 commit e28ae73
Show file tree
Hide file tree
Showing 27 changed files with 219 additions and 87 deletions.
5 changes: 3 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ INIT_APP_TIMEOUT=10000
ROOT_STATE_STORAGE_KEY=root

# Same as MARKETING_VERSION in iOS / version in Android
APP_MARKETING_VERSION=0.26.0
APP_MARKETING_VERSION=0.27.2

# Same as CURRENT_PROJECT_VERSION in iOS / version code in Android
APP_VERSION=287
APP_VERSION=300

# APP_VERSION must be greater or equal to the this value
# without forcing user to update the app
Expand Down Expand Up @@ -41,6 +41,7 @@ COSMOS_DENOM=LIKE
COSMOS_FRACTION_DENOM=nanolike
COSMOS_FRACTION_DIGITS=9
COSMOS_GAS_PRICE=0
COSMOS_ADDRESS_PREFIX=cosmos
GAS_SEND=80000
GAS_DELEGATE=160000
GAS_REDELEGATE=360000
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 10
node-version: 14
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
Expand All @@ -42,7 +42,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 10
node-version: 14
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/production_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 10
node-version: 14
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 10
node-version: 14
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 10
node-version: 14
- name: Set release version and build number env
id: version-format
run: |
Expand Down Expand Up @@ -76,7 +76,7 @@ jobs:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 10
node-version: 14
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ android {
applicationId "com.oice"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 287
versionName "0.26.0"
versionCode 300
versionName "0.27.2"
missingDimensionStrategy 'react-native-camera', 'general'
}
splits {
Expand Down
2 changes: 1 addition & 1 deletion app/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"civic_liker_v3_summary_hint_civic_liker": "Civic Liker",
"civic_liker_v3_summary_hint_inactive": "Stake at least %{amount} to become %{civicLiker}",
"civic_liker_v3_summary_hint_activating": "Stake %{amount} more to become %{civicLiker}",
"civic_liker_v3_summary_hint_active": "You have staked %{amount}. The more you stake, the more you reward.",
"civic_liker_v3_summary_hint_active": "You have staked %{amount}. The more you stake, the more you reward to creators.",
"civic_liker_v3_summary_hint_undelegate": "You need to stake %{amount} to keep your %{civicLiker} status",
"civic_liker_v3_summary_manage_button_active": "Restake",
"civic_liker_v3_summary_manage_button_inactive": "Stake now",
Expand Down
2 changes: 2 additions & 0 deletions app/models/creator/creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ export const CreatorModel = UserModel.named("Creator")
displayName,
avatar: avatarURL,
cosmosWallet,
likeWallet,
isSubscribedCivicLiker,
} = result.data
self.displayName = displayName
self.avatarURL = avatarURL
self.cosmosWallet = cosmosWallet
self.likeWallet = likeWallet
self.isCivicLiker = isSubscribedCivicLiker
break
}
Expand Down
3 changes: 2 additions & 1 deletion app/models/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class Environment {
AUTHCORE_ROOT_URL,
COSMOS_LCD_URL,
COSMOS_CHAIN_ID,
COSMOS_ADDRESS_PREFIX,
LIKECO_API_URL,
LIKECOIN_API_URL,
LIKERLAND_API_URL,
Expand All @@ -44,7 +45,7 @@ export class Environment {
if (SENTRY_DSN) {
initSentry(SENTRY_DSN, SENTRY_ENV)
}
this.authCoreAPI.setup(AUTHCORE_ROOT_URL, COSMOS_CHAIN_ID)
this.authCoreAPI.setup(AUTHCORE_ROOT_URL, COSMOS_CHAIN_ID, COSMOS_ADDRESS_PREFIX)
this.likeCoAPI.setup(LIKECO_API_URL)
this.likeCoinAPI.setup(LIKECOIN_API_URL)
this.likerLandAPI.setup(LIKERLAND_API_URL)
Expand Down
2 changes: 2 additions & 0 deletions app/models/supporter/supporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ export const SupporterModel = UserModel
displayName,
avatar: avatarURL,
cosmosWallet,
likeWallet,
isSubscribedCivicLiker,
} = result.data
self.displayName = displayName
self.avatarURL = avatarURL
self.cosmosWallet = cosmosWallet
self.likeWallet = likeWallet
self.isCivicLiker = isSubscribedCivicLiker
break
}
Expand Down
15 changes: 14 additions & 1 deletion app/models/transfer-store/transfer-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,18 @@ export const TransferStoreModel = TxStoreModel
}))
.views(self => ({
get receiverAddress() {
return self.liker ? self.liker.cosmosWallet : self.target
const addressPrefix = self.env.appConfig.getValue("COSMOS_ADDRESS_PREFIX")
if (self.liker) {
switch (addressPrefix) {
case "like":
return self.liker.likeWallet

case "cosmos":
default:
return self.liker.cosmosWallet
}
}
return self.target
},
}))
.actions(self => {
Expand All @@ -33,6 +44,7 @@ export const TransferStoreModel = TxStoreModel
email,
avatar: avatarURL,
cosmosWallet,
likeWallet,
} = result.data
if (likerID) {
self.liker = UserModel.create({
Expand All @@ -41,6 +53,7 @@ export const TransferStoreModel = TxStoreModel
email,
avatarURL,
cosmosWallet,
likeWallet,
})
}
break
Expand Down
33 changes: 32 additions & 1 deletion app/models/user-store/user-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import {
SnapshotOut,
types,
} from "mobx-state-tree"
import {
ImagePickerResponse,
launchImageLibrary,
} from "react-native-image-picker"

import { withEnvironment } from "../extensions"
import { UserModel } from "../user"
Expand Down Expand Up @@ -177,6 +181,33 @@ export const UserStoreModel = types
applySnapshot(self.appMeta, {})
}
}),
updateUserAvatar: flow(function * () {
const oldAvatarURL = self.currentUser.avatarURL
try {
const response: ImagePickerResponse = yield launchImageLibrary({
mediaType: 'photo',
})
if (response.didCancel || response.errorCode) return

const [{ uri, fileName: name, type }] = response.assets
self.currentUser.avatarURL = uri
const result: GeneralResult = yield self.env.likeCoAPI.updateAvatar({
uri,
name,
type,
})
switch (result.kind) {
case "ok": {
break
}
default:
throwProblem(result)
}
} catch (error) {
logError(error)
self.currentUser.avatarURL = oldAvatarURL
}
}),
updateUserFromResultData(data: User) {
const {
user: likerID,
Expand Down Expand Up @@ -234,7 +265,7 @@ export const UserStoreModel = types
const cosmosWallet = self.authCore.primaryCosmosAddress
const authCoreUserId = self.authCore.profile.id
const primaryPhone = self.authCore.profile.primaryPhone

if (self.shouldTrackUser) {
/* set branch user id for consistent link data */
self.env.branchIO.setUserIdentity(likerID)
Expand Down
1 change: 1 addition & 0 deletions app/models/user/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const UserModel = types
email: types.maybe(types.string),
avatarURL: types.maybe(types.string),
cosmosWallet: types.maybe(types.string),
likeWallet: types.maybe(types.string),
isCivicLiker: types.optional(types.boolean, false),
isSuperLiker: types.optional(types.boolean, false),
canSuperLike: types.optional(types.boolean, false),
Expand Down
2 changes: 1 addition & 1 deletion app/screens/dashboard-screen/dashboard-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class DashboardScreen extends React.Component<DashboardScreenProps, {}> {
renderHeader() {
return (
<ExtendedView backgroundColor={color.primary}>
<DashboardUserInfoPanel />
<DashboardUserInfoPanel onAvatarUpload={this.props.userStore.updateUserAvatar} />
</ExtendedView>
)
}
Expand Down
12 changes: 8 additions & 4 deletions app/screens/dashboard-screen/dashboard-user-info-panel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from "react"
import { TouchableOpacity } from "react-native"
import { inject, observer } from "mobx-react"
import styled from "styled-components/native"

Expand Down Expand Up @@ -32,6 +33,7 @@ const DisplayNameLabel = styled(Text)`

export interface DashboardUserInfoPanelProps {
userStore?: UserStore
onAvatarUpload?: () => {}
}

@inject(
Expand All @@ -47,10 +49,12 @@ export class DashboardUserInfoPanel extends React.Component<
if (!user) return null
return (
<RootView>
<Avatar
src={user.avatarURL}
isCivicLiker={user.isCivicLiker}
/>
<TouchableOpacity onPress={this.props.onAvatarUpload}>
<Avatar
src={user.avatarURL}
isCivicLiker={user.isCivicLiker}
/>
</TouchableOpacity>
<ContentView>
<LikerIDLabel
text={`Liker ID: ${user.likerID}`}
Expand Down
5 changes: 3 additions & 2 deletions app/screens/notification-screen/notification-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ export class NotificationScreen extends React.Component<Props, {}> {
case "transfer":
const {
likerID: myID,
cosmosWallet: myAddress,
cosmosWallet: myCosmosAddress,
likeWallet: myLikeAddress,
} = this.props.userStore.currentUser
return [myID, myAddress].includes(item.toTarget)
return [myID, myCosmosAddress, myLikeAddress].includes(item.toTarget)
? NotificationType.Receive
: NotificationType.Send

Expand Down
16 changes: 10 additions & 6 deletions app/screens/settings-screen/settings-screen.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from "react"
import { inject } from "mobx-react"
import { TouchableOpacity } from "react-native"
import { inject, observer } from "mobx-react"
import { NavigationTabScreenProps } from "react-navigation-tabs"
import styled, { useTheme } from "styled-components/native"

Expand Down Expand Up @@ -106,6 +107,7 @@ export interface SettingsScreenProps extends NavigationTabScreenProps<{}> {
"userStore",
"experimentalFeatureStore",
)
@observer
export class SettingsScreen extends React.Component<SettingsScreenProps, {}> {
private onPressProfileSettings = () => {
this.props.navigation.navigate("ProfileSettings")
Expand Down Expand Up @@ -163,11 +165,13 @@ export class SettingsScreen extends React.Component<SettingsScreenProps, {}> {
/>
<ScrollView>
<ScrollContentView>
<Avatar
size={94}
src={user.avatarURL}
isCivicLiker={user.isCivicLiker}
/>
<TouchableOpacity onPress={this.props.userStore.updateUserAvatar}>
<Avatar
size={94}
src={user.avatarURL}
isCivicLiker={user.isCivicLiker}
/>
</TouchableOpacity>

<LanguageTableViewCell
titleTx="settingsScreen.Panel.Settings.Language"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export class TransferTargetInputScreen extends React.Component<TransferTargetInp
if (!liker) {
throw new Error("TRANSFER_INPUT_TARGET_INVALID")
}
if (!liker.cosmosWallet) {
if (!(liker.cosmosWallet || liker.likeWallet)) {
throw new Error("TRANSFER_TARGET_NO_WALLET")
}
}
Expand Down
11 changes: 11 additions & 0 deletions app/services/api/api.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface User {
email?: string
avatar?: string
cosmosWallet?: string
likeWallet?: string
isSubscribedCivicLiker?: boolean
}

Expand Down Expand Up @@ -252,3 +253,13 @@ export type CurrentUserContentSuperLikeStatResult =
data: UserContentSuperLikeStat
}
| GeneralApiProblem

export interface UserAvatarUpdateResponse {
avatar?: string
}
export type UserAvatarUpdateResult =
{
kind: "ok"
data: UserAvatarUpdateResponse
}
| GeneralApiProblem
25 changes: 25 additions & 0 deletions app/services/api/likeco-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,31 @@ export class LikeCoAPI {
}
}

/**
* Update current user avatar
*/
async updateAvatar(file: {
uri: string;
name: string;
type: string;
}): Promise<Types.UserAvatarUpdateResult> {
const data = new FormData();
data.append('avatarFile', file);

const response: ApiResponse<Types.UserAvatarUpdateResponse> =
await this.apisauce.post("/users/update/avatar", data)

if (!response.ok) {
const problem = getGeneralApiProblem(response)
if (problem) return problem
}

return {
kind: "ok",
data: response.data,
}
}

/**
* Fetch content info
*/
Expand Down
Loading

0 comments on commit e28ae73

Please sign in to comment.