From c574f5b53fd13d2668a3730f7d3257fdafca0220 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 9 Oct 2024 18:36:19 +0200 Subject: [PATCH 1/3] Change how migrations duplicated between glitch and upstream are handled (#2878) --- config/initializers/0_duplicate_migrations.rb | 56 ------------------- ...20180410220657_glitch_create_bookmarks.rb} | 11 ++-- db/migrate/20180831171112_create_bookmarks.rb | 11 +++- 3 files changed, 15 insertions(+), 63 deletions(-) delete mode 100644 config/initializers/0_duplicate_migrations.rb rename db/migrate/{20180410220657_create_bookmarks.rb => 20180410220657_glitch_create_bookmarks.rb} (70%) diff --git a/config/initializers/0_duplicate_migrations.rb b/config/initializers/0_duplicate_migrations.rb deleted file mode 100644 index f99357187702d6..00000000000000 --- a/config/initializers/0_duplicate_migrations.rb +++ /dev/null @@ -1,56 +0,0 @@ -# frozen_string_literal: true - -# Some migrations have been present in glitch-soc for a long time and have then -# been merged in upstream Mastodon, under a different version number. -# -# This puts us in an uneasy situation in which if we remove upstream's -# migration file, people migrating from upstream will end up having a conflict -# with their already-ran migration. -# -# On the other hand, if we keep upstream's migration and remove our own, -# any current glitch-soc user will have a conflict during migration. -# -# For lack of a better solution, as those migrations are indeed identical, -# we decided monkey-patching Rails' Migrator to completely ignore the duplicate, -# keeping only the one that has run, or an arbitrary one. - -ALLOWED_DUPLICATES = [2018_04_10_220657, 2018_08_31_171112].freeze - -module ActiveRecord - class Migrator - def self.new(direction, migrations, schema_migration, internal_metadata, target_version = nil) - migrated = Set.new(Base.connection.migration_context.get_all_versions) - - migrations.group_by(&:name).each_value do |duplicates| - next unless duplicates.length > 1 && duplicates.all? { |m| ALLOWED_DUPLICATES.include?(m.version) } - - # We have a set of allowed duplicates. Keep the migrated one, if any. - non_migrated = duplicates.reject { |m| migrated.include?(m.version.to_i) } - - migrations = begin - if duplicates.length == non_migrated.length || non_migrated.empty? - # There weren't any migrated one, so we have to pick one “canonical” migration - migrations - duplicates[1..] - else - # Just reject every duplicate which hasn't been migrated yet - migrations - non_migrated - end - end - end - - super - end - end - - class MigrationContext - def needs_migration? - # A set of duplicated migrations is considered migrated if at least one of - # them is migrated. - migrated = get_all_versions - migrations.group_by(&:name).each_value do |duplicates| - return true unless duplicates.any? { |m| migrated.include?(m.version.to_i) } - end - false - end - end -end diff --git a/db/migrate/20180410220657_create_bookmarks.rb b/db/migrate/20180410220657_glitch_create_bookmarks.rb similarity index 70% rename from db/migrate/20180410220657_create_bookmarks.rb rename to db/migrate/20180410220657_glitch_create_bookmarks.rb index aba21f5eaae23f..5a2e0d35e5a691 100644 --- a/db/migrate/20180410220657_create_bookmarks.rb +++ b/db/migrate/20180410220657_glitch_create_bookmarks.rb @@ -1,10 +1,11 @@ # frozen_string_literal: true -# This migration is a duplicate of 20180831171112 and may get ignored, see -# config/initializers/0_duplicate_migrations.rb +# This migration is a duplicate of 20180831171112 + +class GlitchCreateBookmarks < ActiveRecord::Migration[5.1] + def up + return if table_exists?(:bookmarks) -class CreateBookmarks < ActiveRecord::Migration[5.1] - def change create_table :bookmarks do |t| t.references :account, null: false t.references :status, null: false @@ -19,4 +20,6 @@ def change add_index :bookmarks, [:account_id, :status_id], unique: true end + + def down; end end diff --git a/db/migrate/20180831171112_create_bookmarks.rb b/db/migrate/20180831171112_create_bookmarks.rb index 4fa4c323d64858..88fb75a5977fa0 100644 --- a/db/migrate/20180831171112_create_bookmarks.rb +++ b/db/migrate/20180831171112_create_bookmarks.rb @@ -1,10 +1,11 @@ # frozen_string_literal: true -# This migration is a duplicate of 20180410220657 and may get ignored, see -# config/initializers/0_duplicate_migrations.rb +# This migration is a duplicate of 20180410220657 class CreateBookmarks < ActiveRecord::Migration[5.2] - def change + def up + return if table_exists?(:bookmarks) + create_table :bookmarks do |t| t.references :account, null: false t.references :status, null: false @@ -19,4 +20,8 @@ def change add_index :bookmarks, [:account_id, :status_id], unique: true end + + def down + drop_table :bookmarks + end end From 6e96ec840d9fdf0ba83f48d8482b2bcdd573c08e Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 10 Oct 2024 19:31:51 +0200 Subject: [PATCH 2/3] Fix the favicon notification badge not using the correct notification count (#2880) Fixes #2879 --- app/javascript/flavours/glitch/features/ui/index.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/javascript/flavours/glitch/features/ui/index.jsx b/app/javascript/flavours/glitch/features/ui/index.jsx index d1165194ba32bd..1ef29f8db20eda 100644 --- a/app/javascript/flavours/glitch/features/ui/index.jsx +++ b/app/javascript/flavours/glitch/features/ui/index.jsx @@ -21,6 +21,7 @@ import { Permalink } from 'flavours/glitch/components/permalink'; import { PictureInPicture } from 'flavours/glitch/features/picture_in_picture'; import { identityContextPropShape, withIdentity } from 'flavours/glitch/identity_context'; import { layoutFromWindow } from 'flavours/glitch/is_mobile'; +import { selectUnreadNotificationGroupsCount } from 'flavours/glitch/selectors/notifications'; import { WithRouterPropTypes } from 'flavours/glitch/utils/react_router'; import { uploadCompose, resetCompose, changeComposeSpoilerness } from '../../actions/compose'; @@ -90,7 +91,7 @@ const mapStateToProps = state => ({ hasMediaAttachments: state.getIn(['compose', 'media_attachments']).size > 0, canUploadMore: !state.getIn(['compose', 'media_attachments']).some(x => ['audio', 'video'].includes(x.get('type'))) && state.getIn(['compose', 'media_attachments']).size < 4, isWide: state.getIn(['local_settings', 'stretch']), - unreadNotifications: state.getIn(['notifications', 'unread']), + unreadNotifications: selectUnreadNotificationGroupsCount(state), showFaviconBadge: state.getIn(['local_settings', 'notifications', 'favicon_badge']), hicolorPrivacyIcons: state.getIn(['local_settings', 'hicolor_privacy_icons']), moved: state.getIn(['accounts', me, 'moved']) && state.getIn(['accounts', state.getIn(['accounts', me, 'moved'])]), From 888e6a3439ed1324a53d1085a2b293809c9e1eb6 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 11 Oct 2024 17:45:07 +0200 Subject: [PATCH 3/3] Fix setting to hide the quick filter bar (#2882) Fixes #2881 --- .../glitch/features/notifications_v2/filter_bar.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/javascript/flavours/glitch/features/notifications_v2/filter_bar.tsx b/app/javascript/flavours/glitch/features/notifications_v2/filter_bar.tsx index 1299796662b1d6..d9a6b4d07fb57a 100644 --- a/app/javascript/flavours/glitch/features/notifications_v2/filter_bar.tsx +++ b/app/javascript/flavours/glitch/features/notifications_v2/filter_bar.tsx @@ -14,6 +14,7 @@ import { Icon } from 'flavours/glitch/components/icon'; import { selectSettingsNotificationsQuickFilterActive, selectSettingsNotificationsQuickFilterAdvanced, + selectSettingsNotificationsQuickFilterShow, } from 'flavours/glitch/selectors/settings'; import { useAppDispatch, useAppSelector } from 'flavours/glitch/store'; @@ -65,6 +66,11 @@ export const FilterBar: React.FC = () => { const advancedMode = useAppSelector( selectSettingsNotificationsQuickFilterAdvanced, ); + const useFilterBar = useAppSelector( + selectSettingsNotificationsQuickFilterShow, + ); + + if (!useFilterBar) return null; if (advancedMode) return (