Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.
Merged

2.4.78 #4345

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
6d16fb7
Refetch critical data when a network connection is lost and restored
brianlovin Nov 21, 2018
8373761
Fix flow and move navbar refetches to the right components
brianlovin Nov 21, 2018
9934945
Merge alpha and fix conflicts
brianlovin Nov 23, 2018
82f429e
Fix dumb merge
brianlovin Nov 23, 2018
d048809
Detect page visibility changes to trigger refetches
brianlovin Nov 23, 2018
469c43c
Fix flow
brianlovin Nov 23, 2018
13ff2a4
Fix default param value
brianlovin Nov 23, 2018
2a43f59
Merge branch 'alpha' into reconnect-fetches
brianlovin Nov 24, 2018
0a7575c
Fix react modal ssr
brianlovin Nov 26, 2018
900d577
Fix dom property on navbar
brianlovin Nov 26, 2018
fde206a
Fix possible memory leaks on unmounted hover profiles
brianlovin Nov 26, 2018
100de1d
Fix invalid dom properties
brianlovin Nov 26, 2018
7d3156d
Fix dom prop name
brianlovin Nov 26, 2018
1950d3e
Actually fix invalid dom property in navbar
brianlovin Nov 26, 2018
284e994
Dont console entire error from athena catch
brianlovin Nov 26, 2018
b798b22
Fix user onboarding flow when viewing content
brianlovin Nov 26, 2018
2479832
Warn team members before leaving owned-community
brianlovin Nov 26, 2018
dbaf594
Fix thread share meta images
brianlovin Nov 26, 2018
5f4c2e4
Fix flow
brianlovin Nov 26, 2018
6c57f75
Add helpers to sign images in db records
brianlovin Nov 26, 2018
273cbfa
Fix flow issues and return types
brianlovin Nov 26, 2018
708e9aa
Improve the ergonomics of signing images with good defaults and try/c…
brianlovin Nov 26, 2018
3385858
Sign objects in notifications for properly signed image urls in emails
brianlovin Nov 26, 2018
f95c295
Gets rid of expiration setting in context, in favor of sensible defau…
brianlovin Nov 26, 2018
f57c9f1
Merge pull request #4334 from withspectrum/bug-fixes
mxstbr Nov 26, 2018
9b9435d
Merge pull request #4336 from withspectrum/fix-thread-share-meta-images
mxstbr Nov 26, 2018
c3db8b8
Don't double-connect to db from workers
mxstbr Nov 26, 2018
8ebdc9e
Improve some old queries
mxstbr Nov 26, 2018
2424107
Add *AndRole indexes to usersChannels
mxstbr Nov 26, 2018
a7094c6
Fix a goof
mxstbr Nov 26, 2018
b55d39c
Fix all member queries to also include mods and owners, like before
mxstbr Nov 26, 2018
24abff0
Switch to new ordering in snapshot tests
mxstbr Nov 26, 2018
12859f0
Fix DMThread.snippet database performance
mxstbr Nov 26, 2018
8ec8ed5
Merge pull request #4341 from withspectrum/fix-dm-thread-snippet-read
brianlovin Nov 26, 2018
d1b9502
Merge pull request #4339 from withspectrum/enable-db-caching
brianlovin Nov 26, 2018
6ddd494
Merge branch 'alpha' of github.com:withspectrum/spectrum into more-cl…
brianlovin Nov 26, 2018
4e6ea36
Even more clear buttons, warn all members before leaving
brianlovin Nov 26, 2018
ffe7bea
Update electron-window-state to version 5.0.3
depfu[bot] Nov 26, 2018
31d37d1
Fix e2e
brianlovin Nov 26, 2018
0090307
fixes issue where scrollbar appears under segmented controls on deskt…
superbryntendo Nov 26, 2018
a1e4496
Fix e2e
brianlovin Nov 26, 2018
1254fa0
Merge pull request #4342 from withspectrum/depfu/update/desktop/yarn/…
brianlovin Nov 26, 2018
371fa21
Merge pull request #4343 from withspectrum/segment-scroll-fix
brianlovin Nov 26, 2018
bd9a3e0
Merge pull request #4335 from withspectrum/more-clear-leave-buttons
brianlovin Nov 26, 2018
d9e99c8
Merge alpha and fix conflicts
brianlovin Nov 26, 2018
5917ec7
Merge branch 'reconnect-fetches' of github.com:withspectrum/spectrum …
brianlovin Nov 26, 2018
d7ef826
Resolve to safe event-stream dep version
brianlovin Nov 26, 2018
1f69459
Add yarn dep to deploy
brianlovin Nov 26, 2018
03b2344
Fix dm inbox infinite fetching while a fetch is already happening
brianlovin Nov 26, 2018
fa2e689
Merge pull request #4290 from withspectrum/reconnect-fetches
brianlovin Nov 26, 2018
39248b1
Merge branch 'alpha' of github.com:withspectrum/spectrum into sign-im…
brianlovin Nov 26, 2018
e357382
Merge alpha and fix buttons
brianlovin Nov 26, 2018
987853d
Fix bugs
brianlovin Nov 26, 2018
845b50e
Yarn
brianlovin Nov 26, 2018
f88a728
Ignore flow for now
brianlovin Nov 26, 2018
497c4e2
Merge pull request #4344 from withspectrum/fix-settings-buttons
brianlovin Nov 27, 2018
251c4ee
Merge branch 'alpha' of github.com:withspectrum/spectrum into 2.4.78
brianlovin Nov 27, 2018
4272260
2.4.78
brianlovin Nov 27, 2018
b97b490
Add analytics as server option in PR template
brianlovin Nov 27, 2018
7efb55f
Merge pull request #4346 from withspectrum/update-pr-template
mxstbr Nov 27, 2018
918553c
Add communities "memberCount" index, rewrite chronos queries
mxstbr Nov 27, 2018
49100bf
Use message threadIdAndTimestamp index for getNewMessageCount query
mxstbr Nov 27, 2018
66f63c2
Clean up bad copy-and-paste queries
mxstbr Nov 27, 2018
4a25022
Update babel-plugin-styled-components to version 1.9.0
depfu[bot] Nov 27, 2018
76650bc
Use threadIdAndTimestamp index in mercury db query
mxstbr Nov 27, 2018
4a3e54f
Merge pull request #4351 from withspectrum/depfu/update/api/yarn/babe…
mxstbr Nov 27, 2018
490a36d
Merge pull request #4349 from withspectrum/community-member-count-ind…
brianlovin Nov 27, 2018
5c86138
Merge pull request #4350 from withspectrum/fix-chronos-message-queries
brianlovin Nov 27, 2018
d334824
Merge pull request #4352 from withspectrum/mercury-db-queries
brianlovin Nov 27, 2018
1e405f6
Merge pull request #4337 from withspectrum/sign-images-sent-in-emails
brianlovin Nov 27, 2018
0ada3f9
Fix channel join leave buttons
brianlovin Nov 27, 2018
9811ac4
Merge pull request #4354 from withspectrum/fix-channel-joing-buttons
brianlovin Nov 27, 2018
d523ff7
Fix nit
brianlovin Nov 27, 2018
d832592
Merge pull request #4340 from withspectrum/users-channels-role-index
brianlovin Nov 27, 2018
508cf18
Merge branch 'alpha' of github.com:withspectrum/spectrum into 2.4.78
brianlovin Nov 27, 2018
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
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- hermes
- chronos
- mobile
- analytics

**Run database migrations (delete if no migration was added)**
YES
Expand Down
2 changes: 1 addition & 1 deletion analytics/models/channel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import type { DBChannel } from 'shared/types';
import { db } from './db';
import { db } from 'shared/db';

export const getChannelById = (channelId: string): Promise<DBChannel> => {
return db
Expand Down
2 changes: 1 addition & 1 deletion analytics/models/community.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import type { DBCommunity } from 'shared/types';
import { db } from './db';
import { db } from 'shared/db';

export const getCommunityById = (communityId: string): Promise<DBCommunity> => {
return db
Expand Down
31 changes: 0 additions & 31 deletions analytics/models/db.js

This file was deleted.

2 changes: 1 addition & 1 deletion analytics/models/message.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import type { DBMessage } from 'shared/types';
import { db } from './db';
import { db } from 'shared/db';

export const getMessageById = (messageId: string): Promise<DBMessage> => {
return db
Expand Down
2 changes: 1 addition & 1 deletion analytics/models/notification.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import type { DBNotification } from 'shared/types';
import { db } from './db';
import { db } from 'shared/db';

export const getNotificationById = (
notificationId: string
Expand Down
2 changes: 1 addition & 1 deletion analytics/models/reaction.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import type { DBReaction, DBThreadReaction } from 'shared/types';
import { db } from './db';
import { db } from 'shared/db';

export const getReactionById = (reactionId: string): Promise<DBReaction> => {
return db
Expand Down
2 changes: 1 addition & 1 deletion analytics/models/thread.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import type { DBThread } from 'shared/types';
import { db } from './db';
import { db } from 'shared/db';

export const getThreadById = (threadId: string): Promise<DBThread> => {
return db
Expand Down
2 changes: 1 addition & 1 deletion analytics/models/usersChannels.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import type { DBUsersChannels } from 'shared/types';
import { db } from './db';
import { db } from 'shared/db';

const defaultResult = {
isMember: false,
Expand Down
2 changes: 1 addition & 1 deletion analytics/models/usersCommunities.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import type { DBUsersCommunities } from 'shared/types';
import { db } from './db';
import { db } from 'shared/db';

const defaultResult = {
isMember: false,
Expand Down
2 changes: 1 addition & 1 deletion analytics/models/usersThreads.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import type { DBUsersThreads } from 'shared/types';
import { db } from './db';
import { db } from 'shared/db';

export const getThreadNotificationStatusForUser = (
threadId: string,
Expand Down
30 changes: 0 additions & 30 deletions api/apollo-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,6 @@ const server = new ProtectedApolloServer({
req.login(data, err => (err ? rej(err) : res()))
),
user: currentUser,
getImageSignatureExpiration: () => {
/*
Expire images sent to the client at midnight each day (UTC).
Expiration needs to be consistent across all images in order
to preserve client-side caching abilities and to prevent checksum
mismatches during SSR
*/
const date = new Date();
date.setHours(24);
date.setMinutes(0);
date.setSeconds(0);
date.setMilliseconds(0);
return date.getTime();
},
};
},
subscriptions: {
Expand All @@ -98,28 +84,12 @@ const server = new ProtectedApolloServer({
return {
user: user || null,
loaders: createLoaders({ cache: false }),
getImageSignatureExpiration: () => {
const date = new Date();
date.setHours(24);
date.setMinutes(0);
date.setSeconds(0);
date.setMilliseconds(0);
return date.getTime();
},
};
})
.catch(err => {
console.error(err);
return {
loaders: createLoaders({ cache: false }),
getImageSignatureExpiration: () => {
const date = new Date();
date.setHours(24);
date.setMinutes(0);
date.setSeconds(0);
date.setMilliseconds(0);
return date.getTime();
},
};
}),
},
Expand Down
1 change: 0 additions & 1 deletion api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import type { Loader } from './loaders/types';
export type GraphQLContext = {
user: DBUser,
updateCookieUserData: (data: DBUser) => Promise<void>,
getImageSignatureExpiration: () => number,
loaders: {
[key: string]: Loader,
},
Expand Down
6 changes: 3 additions & 3 deletions api/loaders/directMessageThread.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
import { getDirectMessageThreads } from '../models/directMessageThread';
import { getMembersInDirectMessageThreads } from '../models/usersDirectMessageThreads';
import { getLastMessages } from '../models/message';
import { getLastMessageOfThreads } from '../models/message';
import createLoader from './create-loader';
import type { Loader } from './types';

Expand All @@ -15,8 +15,8 @@ export const __createDirectMessageParticipantsLoader = createLoader(
);

export const __createDirectMessageSnippetLoader = createLoader(
threads => getLastMessages(threads),
'group'
threads => getLastMessageOfThreads(threads),
'threadId'
);

export default () => {
Expand Down
59 changes: 59 additions & 0 deletions api/migrations/20181126094455-users-channels-roles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const branch = (r, field, fallback) => {
return r.branch(r.row(`is${field}`).eq(true), field.toLowerCase(), fallback);
};

exports.up = function(r, conn) {
return Promise.all([
r
.table('usersChannels')
.indexCreate('channelIdAndRole', [
r.row('channelId'),
branch(
r,
'Pending',
branch(
r,
'Blocked',
branch(
r,
'Owner',
branch(r, 'Moderator', branch(r, 'Member', r.literal()))
)
)
),
])
.run(conn),
r
.table('usersChannels')
.indexCreate('userIdAndRole', [
r.row('userId'),
branch(
r,
'Pending',
branch(
r,
'Blocked',
branch(
r,
'Owner',
branch(r, 'Moderator', branch(r, 'Member', r.literal()))
)
)
),
])
.run(conn),
]);
};

exports.down = function(r, conn) {
return Promise.all([
r
.table('usersChannels')
.indexDrop('channelIdAndRole')
.run(conn),
r
.table('usersChannels')
.indexDrop('userIdAndRole')
.run(conn),
]);
};
13 changes: 13 additions & 0 deletions api/migrations/20181127090014-communities-member-count-index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
exports.up = function(r, conn) {
return r
.table('communities')
.indexCreate('memberCount')
.run(conn);
};

exports.down = function(r, conn) {
return r
.table('communities')
.indexDrop('memberCount')
.run(conn);
};
22 changes: 14 additions & 8 deletions api/models/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,28 @@ const getChannelsByUser = (userId: string): Promise<Array<DBChannel>> => {
);
};

// prettier-ignore
const getChannelBySlug = (channelSlug: string, communitySlug: string): Promise<DBChannel> => {
const getChannelBySlug = async (
channelSlug: string,
communitySlug: string
): Promise<?DBChannel> => {
const [communityId] = await db
.table('communities')
.getAll(communitySlug, { index: 'slug' })('id')
.run();

if (!communityId) return null;

return db
.table('channels')
.getAll(communityId, { index: 'communityId' })
.filter(channel =>
channel('slug')
.eq(channelSlug)
.and(db.not(channel.hasFields('deletedAt')))
)
.eqJoin('communityId', db.table('communities'))
.filter({ right: { slug: communitySlug } })
.run()
.then(result => {
if (result && result[0]) {
return result[0].left;
}
.then(res => {
if (Array.isArray(res) && res.length > 0) return res[0];
return null;
});
};
Expand Down
26 changes: 14 additions & 12 deletions api/models/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,25 @@ export const getMessages = (
return getForwardMessages(threadId, { first, after });
};

export const getLastMessage = (threadId: string): Promise<DBMessage> => {
export const getLastMessage = (threadId: string): Promise<?DBMessage> => {
return db
.table('messages')
.getAll(threadId, { index: 'threadId' })
.between([threadId, db.minval], [threadId, db.maxval], {
index: 'threadIdAndTimestamp',
leftBound: 'open',
rightBound: 'closed',
})
.orderBy({ index: db.desc('threadIdAndTimestamp') })
.filter(db.row.hasFields('deletedAt').not())
.max('timestamp')
.run();
.limit(1)
.run()
.then(res => (Array.isArray(res) && res.length > 0 ? res[0] : null));
};

export const getLastMessages = (threadIds: Array<string>): Promise<Object> => {
return db
.table('messages')
.getAll(...threadIds, { index: 'threadId' })
.filter(db.row.hasFields('deletedAt').not())
.group('threadId')
.max(row => row('timestamp'))
.run();
export const getLastMessageOfThreads = (
threadIds: Array<string>
): Promise<Array<?DBMessage>> => {
return Promise.all(threadIds.map(id => getLastMessage(id)));
};

// prettier-ignore
Expand Down
6 changes: 2 additions & 4 deletions api/models/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ export const getPrivateCommunityIdsForUsersThreads = (
export const getUsersJoinedChannels = (userId: string): Promise<Array<string>> => {
return db
.table('usersChannels')
.getAll(userId, { index: 'userId' })
.filter({ isMember: true })
.getAll([userId, "member"], [userId, "moderator"], [userId, "owner"], { index: 'userIdAndRole' })
.eqJoin('channelId', db.table('channels'))
.filter(row => row('right').hasFields('deletedAt').not())
.zip()
Expand All @@ -114,8 +113,7 @@ export const getUsersJoinedCommunities = (userId: string): Promise<Array<string>
export const getUsersJoinedPrivateChannelIds = (userId: string): Promise<Array<string>> => {
return db
.table('usersChannels')
.getAll(userId, { index: 'userId' })
.filter({ isMember: true })
.getAll([userId, "member"], [userId, "moderator"], [userId, "owner"], { index: 'userIdAndRole' })
.eqJoin('channelId', db.table('channels'))
.filter(row => row('right')('isPrivate').eq(true).and(row('right').hasFields('deletedAt').not()))
.without({ left: ['id'] })
Expand Down
20 changes: 16 additions & 4 deletions api/models/thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,14 @@ export const getViewableThreadsByUser = async (
// get a list of the channelIds the current user is allowed to see threads
const getCurrentUsersChannelIds = db
.table('usersChannels')
.getAll(currentUser, { index: 'userId' })
.filter({ isBlocked: false, isMember: true })
.getAll(
[currentUser, 'member'],
[currentUser, 'moderator'],
[currentUser, 'owner'],
{
index: 'userIdAndRole',
}
)
.map(userChannel => userChannel('channelId'))
.run();

Expand Down Expand Up @@ -273,8 +279,14 @@ export const getViewableParticipantThreadsByUser = async (
// get a list of the channelIds the current user is allowed to see threads for
const getCurrentUsersChannelIds = db
.table('usersChannels')
.getAll(currentUser, { index: 'userId' })
.filter({ isBlocked: false, isMember: true })
.getAll(
[currentUser, 'member'],
[currentUser, 'moderator'],
[currentUser, 'owner'],
{
index: 'userIdAndRole',
}
)
.map(userChannel => userChannel('channelId'))
.run();

Expand Down
Loading