Skip to content

Commit

Permalink
Merge pull request #382 from woowacourse-teams/release/2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
kouz95 committed Oct 1, 2020
2 parents bed32d2 + 0fc5167 commit 6ad2e67
Show file tree
Hide file tree
Showing 26 changed files with 244 additions and 222 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import org.springframework.transaction.event.TransactionalEventListener;

import com.jikgorae.api.articlefavoritecount.application.ArticleFavoriteCountService;
import com.jikgorae.common.notification.domain.PushToken;
Expand All @@ -24,6 +25,10 @@ public FavoriteCreatedListener(ArticleFavoriteCountService articleFavoriteCountS
@Override
public void onApplicationEvent(FavoriteCreatedEvent event) {
articleFavoriteCountService.increase(event.getFavorite().getArticle());
}

@TransactionalEventListener
public void doAfterFavoriteCreatedEvent(FavoriteCreatedEvent event) {
sendNotification(event);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package com.jikgorae.api.favorite.application;

import java.util.NoSuchElementException;

import org.springframework.context.ApplicationEvent;
import org.springframework.stereotype.Service;

import com.jikgorae.api.article.application.ArticleViewService;
import com.jikgorae.api.article.domain.Article;
import com.jikgorae.api.member.domain.Member;
import com.jikgorae.api.member.domain.MemberRepository;
import com.jikgorae.common.notification.domain.NotificationService;
import com.jikgorae.common.notification.domain.PushToken;

Expand All @@ -17,27 +13,22 @@ public class FavoriteNotificationService implements NotificationService {
private static final String MESSAGE = "님이 회원님의 게시글을 찜했습니다.";

private final ArticleViewService articleViewService;
private final MemberRepository memberRepository;

public FavoriteNotificationService(ArticleViewService articleViewService,
MemberRepository memberRepository) {
public FavoriteNotificationService(ArticleViewService articleViewService) {
this.articleViewService = articleViewService;
this.memberRepository = memberRepository;
}

@Override
public String makeMessage(ApplicationEvent applicationEvent) {
FavoriteCreatedEvent event = (FavoriteCreatedEvent)applicationEvent;
Article article = articleViewService.show(event.getFavorite().getArticle().getId());
String author = article.getAuthor().getNickname();
return author + MESSAGE;
String senderNickname = event.getFavorite().getMember().getNickname();
return senderNickname + MESSAGE;
}

@Override
public PushToken getToken(ApplicationEvent applicationEvent) {
FavoriteCreatedEvent event = (FavoriteCreatedEvent)applicationEvent;
Member member = memberRepository.findById(event.getFavorite().getMember().getId())
.orElseThrow(() -> new NoSuchElementException("존재하지 않는 회원입니다."));
return new PushToken(member.getPushToken());
Article article = articleViewService.show(event.getFavorite().getArticle().getId());
return new PushToken(article.getAuthor().getPushToken());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.jikgorae.chat.message.domain.Message;

public class MessageResponse {
private static final long GAP_OF_KST_AND_UTC = 9L;

private String id;
private Long senderId;
private String senderNickname;
Expand All @@ -18,7 +20,8 @@ public class MessageResponse {
public MessageResponse() {
}

public MessageResponse(String id, Long senderId, String senderNickname, Long roomId, String content, LocalDateTime createdTime) {
public MessageResponse(String id, Long senderId, String senderNickname, Long roomId,
String content, LocalDateTime createdTime) {
this.id = id;
this.senderId = senderId;
this.senderNickname = senderNickname;
Expand All @@ -30,7 +33,7 @@ public MessageResponse(String id, Long senderId, String senderNickname, Long roo
public static MessageResponse of(Message message) {
return new MessageResponse(message.getId(), message.getSenderId(),
message.getSenderNickname(), message.getRoomId(), message.getContent(),
message.getCreatedTime().minusHours(9L));
message.getCreatedTime().minusHours(GAP_OF_KST_AND_UTC));
}

public static List<MessageResponse> listOf(List<Message> messages) {
Expand All @@ -39,8 +42,9 @@ public static List<MessageResponse> listOf(List<Message> messages) {
.collect(toList());
}

public void adjustTime() {
this.createdTime = createdTime.plusHours(9L);
public MessageResponse adjustTime() {
return new MessageResponse(id, senderId, senderNickname, roomId, content,
createdTime.plusHours(GAP_OF_KST_AND_UTC));
}

public String getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public MessageController(SimpMessageSendingOperations messagingTemplate,
@MessageMapping(MESSAGE_URI)
public void message(MessageRequest request) {
MessageResponse response = messageService.save(request);
response.adjustTime();
messagingTemplate.convertAndSend(DESTINATION + request.getRoomId(), response);
messagingTemplate.convertAndSend(DESTINATION + request.getRoomId(), response.adjustTime());
}

@GetMapping(MESSAGE_REST_URI)
Expand All @@ -47,6 +46,7 @@ public ResponseEntity<List<MessageResponse>> showAll(@PathVariable Long roomId,

@GetMapping(MESSAGE_REST_URI + NEW)
public ResponseEntity<MessageResponse> showLast(@PathVariable Long roomId) {
return ResponseEntity.ok(messageService.showLast(roomId));
MessageResponse response = messageService.showLast(roomId);
return ResponseEntity.ok(response.adjustTime());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.jikgorae.chat.wholemessage.domain.WholeMessage;

public class WholeMessageResponse {
private static final long GAP_OF_KST_AND_UTC = 9L;

private String id;
private Long senderId;
private String senderNickname;
Expand All @@ -30,21 +32,11 @@ public WholeMessageResponse(String id, Long senderId, String senderNickname,
this.createdTime = createdTime;
}

public WholeMessageResponse(String id, Long senderId, String senderNickname, Long roomId,
String content, LocalDateTime createdTime) {
this.id = id;
this.senderId = senderId;
this.senderNickname = senderNickname;
this.roomId = roomId;
this.content = content;
this.createdTime = createdTime;
}

public static WholeMessageResponse of(WholeMessage wholeMessage) {
return new WholeMessageResponse(wholeMessage.getId(), wholeMessage.getSenderId(),
wholeMessage.getSenderNickname(), wholeMessage.getSenderAvatar(),
wholeMessage.getRoomId(), wholeMessage.getContent(),
wholeMessage.getCreatedTime().minusHours(9L));
wholeMessage.getCreatedTime().minusHours(GAP_OF_KST_AND_UTC));
}

public static List<WholeMessageResponse> listOf(List<WholeMessage> messages) {
Expand All @@ -53,8 +45,9 @@ public static List<WholeMessageResponse> listOf(List<WholeMessage> messages) {
.collect(toList());
}

public void adjustTime() {
this.createdTime = createdTime.plusHours(9L);
public WholeMessageResponse adjustTime() {
return new WholeMessageResponse(id, senderId, senderNickname, senderAvatar, roomId, content,
createdTime.plusHours(GAP_OF_KST_AND_UTC));
}

public String getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,12 @@ public WholeMessageController(SimpMessageSendingOperations messagingTemplate,
@MessageMapping(WHOLE_MESSAGE_URI)
public void message(WholeMessageRequest request) {
WholeMessageResponse response = wholeMessageService.save(request);
response.adjustTime();
messagingTemplate.convertAndSend(DESTINATION_OF_ORGANIZATION + request.getRoomId(),
response);
messagingTemplate.convertAndSend(DESTINATION_OF_ORGANIZATION + request.getRoomId(), response.adjustTime());
}

@GetMapping(WHOLE_MESSAGE_REST_URI)
public ResponseEntity<List<WholeMessageResponse>> showAll(@PathVariable Long organizationId,
@RequestParam int size, @RequestParam String lastMessageDate) {
return ResponseEntity.ok(
wholeMessageService.showAll(organizationId, size, lastMessageDate));
return ResponseEntity.ok(wholeMessageService.showAll(organizationId, size, lastMessageDate));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

public class MessageFixture {
public static MessageRequest requestOf(Long roomId) {
return new MessageRequest(roomId, 99L, "NICKNAME", "MESSAGE", "ExponentPushToken[1234567-12345678901234]");
return new MessageRequest(roomId, 99L, "NICKNAME", "MESSAGE", "PUSH_TOKEN");
}
}
10 changes: 3 additions & 7 deletions front/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"expo": {
"name": "직고래",
"slug": "jikgorae",
"version": "2.0.0",
"version": "2.0.2",
"orientation": "portrait",
"icon": "./assets/app_icon.png",
"splash": {
Expand All @@ -18,12 +18,8 @@
"android": {
"package": "com.sellerleecompany.jikgorae",
"softwareKeyboardLayoutMode": "pan",
"versionCode": 4
},
"ios": {
"bundleIdentifier": "com.sellerleecompany.jikgorae",
"supportsTablet": true,
"buildNumber": "2.0.0"
"versionCode": 6,
"useNextNotificationsApi": true
},
"web": {
"favicon": "./assets/app_icon.png"
Expand Down
Binary file modified front/assets/app_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 19 additions & 17 deletions front/src/components/ArticleDetail/ArticleDetailBottomNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { StackNavigationProp } from "@react-navigation/stack";
import { HomeStackParam } from "../../types/types";
import { useSetRecoilState } from "recoil/dist";
import { chatRoomState } from "../../states/chatRoomState";
import { MaterialCommunityIcons } from "@expo/vector-icons";
import { AntDesign } from "@expo/vector-icons";

export default function ArticleDetailBottomNav() {
const navigation = useNavigation<
Expand Down Expand Up @@ -58,18 +58,21 @@ export default function ArticleDetailBottomNav() {
<View style={styles.favoriteContainer}>
<ArticleDetailFavorite />
</View>
<View style={styles.priceContainer}>
<Text style={styles.price}>{`${insertComma(price.toString())}원`}</Text>
</View>
<View style={styles.chatContainer}>
{memberNickname !== author.nickname ? (
<MaterialCommunityIcons
name="chat-outline"
size={36}
color={"black"}

{memberNickname !== author.nickname ? (
<View style={styles.chatContainer}>
<AntDesign
name="message1"
size={30}
color="black"
onPress={() => createChat(author)}
/>
) : undefined}
</View>
) : (
<></>
)}
<View style={styles.priceContainer}>
<Text style={styles.price}>{`${insertComma(price.toString())}원`}</Text>
</View>
</View>
);
Expand All @@ -86,25 +89,24 @@ const styles = StyleSheet.create({
alignItems: "center",
borderRightWidth: 1,
borderRightColor: theme.border,
paddingRight: 30,
paddingRight: 20,
},
chatContainer: {
justifyContent: "center",
alignItems: "flex-end",
borderLeftWidth: 1,
borderLeftColor: theme.border,
paddingLeft: 30,
borderRightWidth: 1,
borderRightColor: theme.border,
paddingHorizontal: 20,
},
priceContainer: {
flex: 1,
justifyContent: "center",
alignItems: "flex-end",
paddingRight: 20,
},
price: {
fontSize: 24,
fontWeight: "bold",
textAlign: "center",
textAlign: "right",
color: theme.others,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const styles = StyleSheet.create({
alignItems: "center",
},
createTime: {
marginLeft: 5,
fontSize: 12,
marginLeft: 10,
fontSize: 13,
color: "gray",
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,21 @@ export default function ArticleCardTradeState({

const styles = StyleSheet.create({
tradeOnSaleContainer: {
paddingHorizontal: 5,
paddingHorizontal: 10,
backgroundColor: theme.primary,
borderRadius: 10,
justifyContent: "center",
alignItems: "center",
},
tradeReservedContainer: {
paddingHorizontal: 5,
paddingHorizontal: 10,
backgroundColor: theme.secondary,
borderRadius: 10,
justifyContent: "center",
alignItems: "center",
},
tradeCompletedContainer: {
paddingHorizontal: 5,
paddingHorizontal: 10,
backgroundColor: "lightgrey",
borderRadius: 10,
justifyContent: "center",
Expand Down
16 changes: 2 additions & 14 deletions front/src/components/Navigation/HomeStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,8 @@ export default function HomeStack() {
component={CategoryHomeScreen}
/>
<Stack.Screen name={"SelectChatScreen"} component={SelectChatScreen} />
<Stack.Screen
name={"ChatScreen"}
component={ChatScreen}
options={{
headerShown: false,
}}
/>
<Stack.Screen
name={"WholeChatScreen"}
component={WholeChatScreen}
options={{
headerShown: false,
}}
/>
<Stack.Screen name={"ChatScreen"} component={ChatScreen} />
<Stack.Screen name={"WholeChatScreen"} component={WholeChatScreen} />
<Stack.Screen
name={"ProfileScreen"}
component={ProfileScreen}
Expand Down
2 changes: 1 addition & 1 deletion front/src/components/Profile/EnterOrganizationButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function EnterOrganizationButton() {
>
<Feather name="users" size={22} color={theme.primary} />
<View style={styles.titleContainer}>
<Text style={styles.title}>조직 입장/생성</Text>
<Text style={styles.title}>조직 관리</Text>
</View>
</TouchableOpacity>
</View>
Expand Down
2 changes: 1 addition & 1 deletion front/src/components/Profile/ProfileInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function ProfileInfo() {
<View style={styles.container}>
<View style={styles.avatarContainer}>
<Image
source={{ uri: avatar ? avatar : undefined }}
source={{ uri: profile.avatar ? profile.avatar : undefined }}
style={styles.avatar}
defaultSource={require("../../../assets/user.png")}
/>
Expand Down
7 changes: 2 additions & 5 deletions front/src/components/chat/ChatMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function ChatMenu() {
};

return (
<Menu style={styles.container}>
<Menu>
<MenuTrigger>
<Feather name="more-vertical" size={24} color={"black"} />
</MenuTrigger>
Expand All @@ -49,11 +49,8 @@ export default function ChatMenu() {
}

const styles = StyleSheet.create({
container: {
paddingVertical: 5,
},
menuOptions: {
width: 100,
width: 80,
},
menuCustomStyle: {
textAlign: "center",
Expand Down
Loading

0 comments on commit 6ad2e67

Please sign in to comment.