Skip to content
This repository was archived by the owner on Nov 10, 2020. It is now read-only.

Patch1 #134

Merged
merged 13 commits into from
Aug 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,5 @@ release
scripts

app/build

.DS_Store
18 changes: 17 additions & 1 deletion app/src/main/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ const handleRedirect = (e, link) => {
function initTray() {
// No idea why using let or var or const with tray causes the tray not to display anything
/* eslint-disable */
tray = new Tray(path.join(__dirname, '/res/images/devrantLogo512.png'));
let icon = path.join(__dirname, '/res/images/devrantLogo512.png');
if (process.platform === 'darwin') {
icon = path.join(__dirname, '/res/images/devrantLogo24.png');
}
tray = new Tray(icon);
const contextMenu = Menu.buildFromTemplate([
{ label: 'Open App', click() { mainWindow.show(); } },
{ type: 'separator' },
Expand Down Expand Up @@ -205,6 +209,18 @@ app.on('activate', () => {
}
});

if (process.platform === 'darwin') {
app.on('before-quit', () => {
quitApp();
});
app.on('activate', (e, hasVisibleWindow) => {
if (!hasVisibleWindow) {
mainWindow.show();
mainWindow.focus();
}
});
}

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/js/actions/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ const closeModal = () => (dispatch) => {
* @param {string} type Type of the item to show in the modal
* @param {number} id This ID can be either user id or rant/collab id
*/
const openModal = (type, id = 0) => (dispatch) => {
const openModal = (type, id = 0, data = {}) => (dispatch) => {
dispatch({
type: MODAL.OPEN,
item: {
type,
id,
data,
},
});
};
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/js/actions/notifs.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,21 @@ const showNotifs = notif => (dispatch, getState) => {
ipcRenderer.send('showQRNotif', notif);
return;
}
const commentID = notif.content.comment_id || 0;

const myNotification = new Notification('devRantron', {
body: notif.body,
data: notif.id,
data: { id: notif.id, commentID },
icon: 'http://i.imgur.com/iikd00P.png',
silent: !notifSettings.notif_sound_enabled.value,
});

// Open a modal when a user clicks on the notif
myNotification.onclick = (e) => {
dispatch(openModal(ITEM.RANT.NAME, e.target.data));
currentWindow.show();
dispatch(openModal(ITEM.RANT.NAME, e.target.data.id, { commentID: e.target.data.commentID }));
if (!currentWindow.isVisible()) {
currentWindow.show();
}
currentWindow.focus();
};
}
Expand Down
60 changes: 37 additions & 23 deletions app/src/main/js/components/columns/column.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ItemCard from '../item/item_card';
import Loading from '../utilities/loading';
import ColumnTopBar from './column_topbar';
import { getRandomInt } from '../../consts/utils';
import { STATE } from '../../consts/types';

class Column extends Component {
constructor() {
Expand Down Expand Up @@ -72,33 +73,22 @@ class Column extends Component {
updateScrollHeight(this.props.column.id, this.itemsContainer.scrollTop);
}
}
render() {
getItemsContainer() {
const {
column, theme, vote, fetch, open, filters, itemType, removeColumn, auth } = this.props;
column, theme, vote, fetch, open, itemType, auth } = this.props;
const { divID } = this.state;
if (column.items.length === 0 && column.state === STATE.SUCCESS) {
return (
<div className="no_items">Nothing to see here</div>
);
}
return (
<div
className="column"
style={{ width: `${theme.column.width}px` }}
className="items_container"
id={divID}
ref={(node) => { this.itemsContainer = node; }}
>
<ColumnTopBar
filters={filters}
fetch={fetch}
id={column.id}
divID={divID}
fetchAfterMount={column.items.length === 0}
type={column.type}
state={column.state}
removeColumn={removeColumn}
sort={column.sort}
range={column.range}
/>
<div
className="items_container"
id={divID}
ref={(node) => { this.itemsContainer = node; }}
>
{
{
column.items.length === 0 ?
<Loading
backgroundColor={theme.backgroundColor}
Expand All @@ -116,7 +106,31 @@ class Column extends Component {
/>
))
}
</div>
</div>
);
}
render() {
const {
column, theme, fetch, filters, removeColumn } = this.props;
const { divID } = this.state;
return (
<div
className="column"
style={{ width: `${theme.column.width}px` }}
>
<ColumnTopBar
filters={filters}
fetch={fetch}
id={column.id}
divID={divID}
fetchAfterMount={column.items.length === 0}
type={column.type}
state={column.state}
removeColumn={removeColumn}
sort={column.sort}
range={column.range}
/>
{ this.getItemsContainer() }
</div>
);
}
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/js/components/comments/comment_post.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ class CommentPost extends Component {
this.setState({ disabled: false });
});
}

/**
* This is a function used by comments.js to add a user to
* smart area when the reply button is clicked
*
* @memberof CommentPost
*/
addMention(value) {
this.smartArea.addStringToContent(value);
}
render() {
const { theme, auth } = this.props;
return (
Expand All @@ -71,6 +81,7 @@ class CommentPost extends Component {
disabled={this.state.disabled || auth.user === null}
value={this.state.content}
onChange={text => this.setState({ content: text })}
ref={(node) => { this.smartArea = node; }}
/>
</div>
);
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/js/components/comments/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Comments extends Component {
return true;
}
render() {
const { theme, vote, comments, auth, open } = this.props;
const { theme, vote, comments, auth, open, addMention } = this.props;
return (
<div className="comments_container">
{
Expand All @@ -36,6 +36,7 @@ class Comments extends Component {
vote={vote}
auth={auth}
open={open}
addMention={addMention}
/>
))
}
Expand All @@ -50,6 +51,7 @@ Comments.propTypes = {
open: PropTypes.func.isRequired,
comments: PropTypes.array.isRequired,
auth: PropTypes.object.isRequired,
addMention: PropTypes.func.isRequired,
};

export default Comments;
19 changes: 19 additions & 0 deletions app/src/main/js/components/item/bottom_bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ class BottomBar extends Component {
}
this.setState({ isVoted: nextIsVoted, score: nextScore });
}
getAddMention() {
const { addMention, username } = this.props;
if (typeof addMention !== 'undefined') {
return (
<div
className="addMention"
onClick={() => addMention(`@${username}`)}
>
<p><i className="ion-reply" /></p>
</div>
);
}
return <div />;
}
render() {
const { comments, type } = this.props;
const disabled = this.props.isUser ? 'disabled' : '';
Expand Down Expand Up @@ -79,6 +93,9 @@ class BottomBar extends Component {
<span>{ comments }</span>
</div>
}
{
this.getAddMention()
}
</div>
);
}
Expand All @@ -93,6 +110,8 @@ BottomBar.propTypes = {
isVoted: PropTypes.number.isRequired,
id: PropTypes.number.isRequired,
type: PropTypes.string,
addMention: PropTypes.func,
username: PropTypes.string.isRequired,
};

export default BottomBar;
29 changes: 25 additions & 4 deletions app/src/main/js/components/item/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,37 @@ class Item extends Component {
.then((res) => {
const item = res;
this.setState({ item });
if (this.multiCol && scrollToBottom) {
this.multiCol.scrollTop = this.multiCol.scrollHeight;
if (typeof cardItem.data.commentID !== 'undefined') {
const relatedComment = document.getElementById(cardItem.data.commentID);
if (relatedComment) {
relatedComment.scrollIntoView();
}
return;
}
if (this.compactCol && scrollToBottom) {
this.compactCol.scrollTop = this.compactCol.scrollHeight;
if (scrollToBottom) {
if (this.multiCol) {
this.multiCol.scrollTop = this.multiCol.scrollHeight;
}
if (this.compactCol) {
this.compactCol.scrollTop = this.compactCol.scrollHeight;
}
}
fetchNotifs();
})
.catch((err) => {
console.log(err);
});
}
/**
* This is a prop for comments component.
* This just calls the addMention of post comment
*
* @param {string} value
* @memberof Item
*/
addMention(value) {
this.postComment.addMention(value);
}
getItemCard() {
const { item } = this.state;
const { theme, vote, cardItem, auth, open } = this.props;
Expand All @@ -120,6 +139,7 @@ class Item extends Component {
vote={vote}
auth={auth}
open={open}
addMention={value => this.addMention(value)}
/>
);
}
Expand All @@ -134,6 +154,7 @@ class Item extends Component {
id={item.rant.id}
originalPoster={item.rant.user_username}
fetch={() => this.fetchitem(true)}
ref={(node) => { this.postComment = node; }}
/>
);
}
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/js/components/item/item_card.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class ItemCard extends Component {
);
}
render() {
const { item, theme, vote, modal, itemType, auth, open } = this.props;
const { item, theme, vote, modal, itemType, auth, open, addMention } = this.props;
const user = {
avatar: item.user_avatar,
score: item.user_score,
Expand All @@ -132,6 +132,7 @@ class ItemCard extends Component {
return (
<div
className={`item_card ${modal || isComment ? null : 'shadow'}`}
id={item.id}
style={{
backgroundColor: theme.item_card.backgroundColor,
color: theme.item_card.color,
Expand Down Expand Up @@ -174,6 +175,8 @@ class ItemCard extends Component {
id={item.id}
isUser={isUser}
type={isComment ? ITEM.COMMENT.NAME : ITEM.RANT.NAME}
addMention={addMention}
username={user.username}
/>
</div>
);
Expand All @@ -188,6 +191,7 @@ ItemCard.propTypes = {
itemType: PropTypes.string,
open: PropTypes.func,
modal: PropTypes.bool,
addMention: PropTypes.func,
};

export default ItemCard;
4 changes: 3 additions & 1 deletion app/src/main/js/components/user/user_profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class UserProfile extends Component {
if (
nextLength === currentLength
&& nextProps.item.id === this.props.item.id
&& nextState.column.state !== STATE.LOADING
&& (nextState.column.state !== STATE.LOADING && nextState.column.items.length !== 0)
) {
return false;
}
Expand Down Expand Up @@ -100,6 +100,8 @@ class UserProfile extends Component {
} else {
nextColumn.itemType = ITEM.RANT.NAME;
}
console.log(res);
console.log(sort);
this.setState({
user: res,
column: nextColumn,
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/res/css/modules/bottom_bar.sass
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
display: flex
background-color: #40415A
padding: 0.5rem
.addMention
display: flex
align-items: center
p
margin: 0
i
transition: all 0.3s
opacity: 0.4
transform: scale(0.9)
&:hover
cursor: pointer
opacity: 1
transform: scale(1)

.score
flex: 2
font-size: 1rem
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/css/modules/column.sass
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
height: 100vh
overflow: hidden
margin: 0 1rem
.no_items
display: flex
justify-content: center
color: white
margin-top: 5rem
font-size: 1.3rem
.items_container
overflow-x: hidden
overflow-y: scroll
Expand Down
Binary file added app/src/main/res/images/devrantLogo24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/images/devrantLogo32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading