Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Image gallery with swiper #30623

Merged
merged 25 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
aefc9b5
wip
dougfabris Oct 9, 2023
66afd50
feat: image gallery with swipper
juliajforesti Oct 11, 2023
aa2c639
feat: apply IconButton to navigation items
juliajforesti Oct 11, 2023
32b1f3e
refactor: move ImageGallery.tsx file and add loading state
juliajforesti Oct 11, 2023
d3df5d4
fix: remove photoswipeContent
juliajforesti Oct 11, 2023
ee6dd48
fis: stylelint:fix
juliajforesti Oct 11, 2023
2d3c144
Merge branch 'develop' into feat/img-gallery
juliajforesti Oct 18, 2023
cf68502
wip: hook and Files list gallery
juliajforesti Oct 18, 2023
f349d3f
Merge branch 'develop' into feat/img-gallery
juliajforesti Oct 25, 2023
76a0282
feat: sort by recent
juliajforesti Oct 25, 2023
696eb48
feat: load more images
juliajforesti Oct 25, 2023
70337f8
Merge branch 'develop' into feat/img-gallery
juliajforesti Oct 30, 2023
3ae6cf8
refactor: css-in-js
juliajforesti Oct 30, 2023
fdc81b6
refactor: `FIleItem` split ImageItem into new component
juliajforesti Oct 30, 2023
f340ffd
refactor: replace main css content
juliajforesti Oct 30, 2023
c5bc97c
refactor: `useImageGallery`
juliajforesti Oct 30, 2023
38a7e85
ops
juliajforesti Oct 30, 2023
bd4fed4
feat: ImageGallery provider
juliajforesti Oct 30, 2023
d43b6cb
feat: add `channels.images` endpoint (#30822)
pierre-lehnen-rc Nov 1, 2023
cb87393
feat: add `FocusScope`
juliajforesti Nov 1, 2023
34c3250
wip channels.images endpoint implementation
juliajforesti Nov 1, 2023
cd9069d
fix: type
juliajforesti Nov 3, 2023
fb91944
Merge branch 'develop' into feat/img-gallery
ggazzo Dec 4, 2023
8b36bea
remove photoswipe deps
ggazzo Dec 4, 2023
72934b1
fix: remove unused imports
juliajforesti Dec 4, 2023
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: 0 additions & 1 deletion apps/meteor/.meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,5 @@ [email protected]

# photoswipe

jquery
zodern:types
zodern:standard-minifier-js
1 change: 0 additions & 1 deletion apps/meteor/.meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ [email protected]
[email protected]
[email protected]
[email protected]
[email protected]
kadira:[email protected]
[email protected]
[email protected]
Expand Down
45 changes: 44 additions & 1 deletion apps/meteor/app/api/server/v1/channels.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Team, Room } from '@rocket.chat/core-services';
import type { IRoom, ISubscription, IUser, RoomType } from '@rocket.chat/core-typings';
import type { IRoom, ISubscription, IUser, RoomType, IUpload } from '@rocket.chat/core-typings';
import { Integrations, Messages, Rooms, Subscriptions, Uploads, Users } from '@rocket.chat/models';
import {
isChannelsAddAllProps,
Expand All @@ -18,6 +18,7 @@ import {
isChannelsConvertToTeamProps,
isChannelsSetReadOnlyProps,
isChannelsDeleteProps,
isChannelsImagesProps,
} from '@rocket.chat/rest-typings';
import { Meteor } from 'meteor/meteor';

Expand Down Expand Up @@ -803,6 +804,48 @@ API.v1.addRoute(
},
);

API.v1.addRoute(
'channels.images',
{ authRequired: true, validateParams: isChannelsImagesProps },
{
async get() {
const room = await Rooms.findOneById<Pick<IRoom, '_id' | 't' | 'teamId' | 'prid'>>(this.queryParams.roomId, {
projection: { t: 1, teamId: 1, prid: 1 },
});

if (!room || !(await canAccessRoomAsync(room, { _id: this.userId }))) {
return API.v1.unauthorized();
}

let initialImage: IUpload | null = null;
if (this.queryParams.startingFromId) {
initialImage = await Uploads.findOneById(this.queryParams.startingFromId);
}

const { offset, count } = await getPaginationItems(this.queryParams);

const { cursor, totalCount } = Uploads.findImagesByRoomId(room._id, initialImage?.uploadedAt, {
skip: offset,
limit: count,
});

const [files, total] = await Promise.all([cursor.toArray(), totalCount]);

// If the initial image was not returned in the query, insert it as the first element of the list
if (initialImage && !files.find(({ _id }) => _id === (initialImage as IUpload)._id)) {
files.splice(0, 0, initialImage);
}

return API.v1.success({
files,
count,
offset,
total,
});
},
},
);

API.v1.addRoute(
'channels.getIntegrations',
{ authRequired: true },
Expand Down
46 changes: 0 additions & 46 deletions apps/meteor/app/emoji-custom/client/lib/emojiCustom.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { escapeRegExp } from '@rocket.chat/string-helpers';
import $ from 'jquery';
import { Meteor } from 'meteor/meteor';
import { Session } from 'meteor/session';

import { emoji, updateRecent } from '../../../emoji/client';
import { CachedCollectionManager } from '../../../ui-cached-collection/client';
import { LegacyRoomManager } from '../../../ui-utils/client';
import { getURL } from '../../../utils/client';
import { sdk } from '../../../utils/client/lib/SDKClient';
import { isSetNotNull } from './function-isSet';
Expand Down Expand Up @@ -45,9 +43,6 @@ export const deleteEmojiCustom = function (emojiData) {
};

export const updateEmojiCustom = function (emojiData) {
let key = `emoji_random_${emojiData.name}`;
Session.set(key, Math.round(Math.random() * 1000));

const previousExists = isSetNotNull(() => emojiData.previousName);
const currentAliases = isSetNotNull(() => emojiData.aliases);

Expand Down Expand Up @@ -88,47 +83,6 @@ export const updateEmojiCustom = function (emojiData) {
}
}

const url = getEmojiUrlFromName(emojiData.name, emojiData.extension);

// update in admin interface
if (previousExists && emojiData.name !== emojiData.previousName) {
$(document)
.find(`.emojiAdminPreview-image[data-emoji='${emojiData.previousName}']`)
.css('background-image', `url('${url})'`)
.attr('data-emoji', `${emojiData.name}`);
} else {
$(document).find(`.emojiAdminPreview-image[data-emoji='${emojiData.name}']`).css('background-image', `url('${url}')`);
}

// update in picker
if (previousExists && emojiData.name !== emojiData.previousName) {
$(document)
.find(`li[data-emoji='${emojiData.previousName}'] span`)
.css('background-image', `url('${url}')`)
.attr('data-emoji', `${emojiData.name}`);
$(document)
.find(`li[data-emoji='${emojiData.previousName}']`)
.attr('data-emoji', `${emojiData.name}`)
.attr('class', `emoji-${emojiData.name}`);
} else {
$(document).find(`li[data-emoji='${emojiData.name}'] span`).css('background-image', `url('${url}')`);
}

// update in picker and opened rooms
for (key in LegacyRoomManager.openedRooms) {
if (LegacyRoomManager.openedRooms.hasOwnProperty(key)) {
const room = LegacyRoomManager.openedRooms[key];
if (previousExists && emojiData.name !== emojiData.previousName) {
$(room.dom)
.find(`span[data-emoji='${emojiData.previousName}']`)
.css('background-image', `url('${url}')`)
.attr('data-emoji', `${emojiData.name}`);
} else {
$(room.dom).find(`span[data-emoji='${emojiData.name}']`).css('background-image', `url('${url}')`);
}
}
}

updateRecent('rocket');
};

Expand Down
1 change: 0 additions & 1 deletion apps/meteor/app/theme/client/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

/* Legacy theming */
@import 'imports/general/theme_old.css';
@import './vendor/photoswipe.css';
@import './vendor/fontello/css/fontello.css';
@import './rocketchat.font.css';
@import './mentionLink.css';
Expand Down
Loading
Loading