Skip to content

Commit

Permalink
https://github.com/bonfire-networks/bonfire-app/issues/243
Browse files Browse the repository at this point in the history
  • Loading branch information
mayel committed Feb 6, 2024
1 parent 741d3ab commit 73cfe18
Show file tree
Hide file tree
Showing 249 changed files with 2,270 additions and 1,559 deletions.
2 changes: 1 addition & 1 deletion docs/DATABASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ how useful this is in practice, so we might go for a simpler option in future.
Example:

```elixir
defmodule Bonfire.Data.Social.APActivity.Migration do
defmodule Bonfire.Data.Social.APActivity.Migration do
@moduledoc false
use Ecto.Migration
import Needle.Migration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ defmodule Bonfire.Repo.Migrations.InitPointers do
@moduledoc false
use Ecto.Migration
import Needle.Migration
import Needle.ULID.Migration

def up do
init_pointers_ulid_extra()
init_pointers()
end
def up(), do: init(:up)
def down(), do: init(:down)

def down do
init_pointers_ulid_extra()
init_pointers()
defp init(dir) do
# this one is optional but recommended
init_pointers_ulid_extra(dir)
# this one is not optional
init_pointers(dir)
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Bonfire.Federate.ActivityPub.Repo.Migrations.ImportMe do
defmodule Bonfire.Federate.ActivityPub.Repo.Migrations.ImportAP do
@moduledoc false
use Ecto.Migration

Expand Down

This file was deleted.

13 changes: 0 additions & 13 deletions flavours/classic/repo/migrations/20200828094947_import_posts.exs

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@ defmodule Bonfire.Repo.Migrations.ImportClassify do
use Ecto.Migration

def up do
if Code.ensure_loaded?(Bonfire.Classify.Migrations) do
Bonfire.Classify.Migrations.up()
end
Bonfire.Classify.Migrations.up()
end

def down do
if Code.ensure_loaded?(Bonfire.Classify.Migrations) do
Bonfire.Classify.Migrations.down()
end
Bonfire.Classify.Migrations.down()
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Bonfire.Repo.Migrations.ImportSharedUser do
defmodule Bonfire.Data.SharedUser.ImportSharedUser do
@moduledoc false
use Ecto.Migration

Expand Down
8 changes: 8 additions & 0 deletions flavours/classic/repo/migrations/20210128094942_posts.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
defmodule Bonfire.Posts.Repo.Migrations.Import do
@moduledoc false
use Ecto.Migration

import Bonfire.Posts.Migrations

def change, do: migrate_posts()
end
8 changes: 8 additions & 0 deletions flavours/classic/repo/migrations/20210128094943_messages.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
defmodule Bonfire.Messages.Repo.MessagesMigrations do
@moduledoc false
use Ecto.Migration

import Bonfire.Messages.Migrations

def change, do: migrate_messages()
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
defmodule Bonfire.Social.Graph.Repo.Migrations.Import do
@moduledoc false
use Ecto.Migration

import Bonfire.Social.Graph.Migrations

def change, do: migrate_social_graph()
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Bonfire.Social.Repo.Migrations.ProfileImages do
defmodule Bonfire.UI.Me.Repo.Migrations.ProfileImages do
@moduledoc false
use Ecto.Migration

Expand Down
2 changes: 1 addition & 1 deletion flavours/classic/repo/migrations/20210412094946_fp.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Bonfire.Repo.Migrations.FP do
defmodule Bonfire.Social.Repo.Migrations.FeedPublish do
@moduledoc false
use Ecto.Migration

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Bonfire.Social.Repo.Migrations.PeeredURI do
defmodule Bonfire.Federate.ActivityPub.Repo.Migrations.PeeredURI do
@moduledoc false
use Ecto.Migration

Expand Down

This file was deleted.

13 changes: 0 additions & 13 deletions flavours/classic/repo/migrations/20220531084501_seen.exs

This file was deleted.

This file was deleted.

4 changes: 1 addition & 3 deletions flavours/classic/repo/migrations/20230304094943_add_type.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ defmodule Bonfire.Repo.Migrations.ClassifyAddType do
use Ecto.Migration

def up do
if Code.ensure_loaded?(Bonfire.Classify.Migrations) do
Bonfire.Classify.Migrations.add_type()
end
Bonfire.Classify.Migrations.add_type()
end

def down do
Expand Down
12 changes: 4 additions & 8 deletions flavours/classic/repo/migrations/20230304100100_add_tree.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ defmodule Bonfire.Repo.Migrations.ClassifyAddTree do
require Bonfire.Classify.Tree.Migration

def up do
if Code.ensure_loaded?(Bonfire.Classify.Tree.Migration) do
Bonfire.Classify.Tree.Migration.migrate_tree()
Bonfire.Classify.Tree.Migration.migrate_functions()
end
Bonfire.Classify.Tree.Migration.migrate_tree()
Bonfire.Classify.Tree.Migration.migrate_functions()
end

def down do
if Code.ensure_loaded?(Bonfire.Classify.Tree.Migration) do
Bonfire.Classify.Tree.Migration.migrate_functions()
Bonfire.Classify.Tree.Migration.migrate_tree()
end
Bonfire.Classify.Tree.Migration.migrate_functions()
Bonfire.Classify.Tree.Migration.migrate_tree()
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
defmodule Bonfire.Social.Repo.Migrations.ArrayFn do
@moduledoc false
use Ecto.Migration

def up, do: Bonfire.Social.Migrations.add_array_reverse_fn()
def down, do: nil
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule Bonfire.Repo.Migrations.GinIndexes do
defmodule Bonfire.Search.Repo.Migrations.GinIndexes do
use Ecto.Migration

@disable_ddl_transaction true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ const createEditor = async (_this, hidden_input, composer$) => {
referenceElement: trigger,
triggerElement: trigger,
emojiSize: '1.75rem',
className: 'z-[9999]',
className: 'z-[99999999999999999999]',
});


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,77 +17,92 @@ let PreviewActivity = {
mounted() {
this.el.addEventListener("click", e => {
console.log("PreviewActivity clicked")
console.log("where clicked")
let trigger = this.el.querySelector('.open_preview_link')
let anchor = e.target.closest('a')
let anchor = e.target.closest('a')
console.log(e.target)

// this was used to expand long posts by clicking on them, now replaced with a 'Read more' button
// let previewable_activity = e.target.closest('.previewable_activity')
// anchor == trigger || (!anchor && previewable_activity && ( previewable_activity.classList.contains('previewable_expanded') || this.isTruncated(previewable_activity.querySelector('.previewable_truncate')) == false)

if ((trigger || !window.liveSocket) && ((!anchor || anchor.classList.contains('preview_activity_link')) && !e.ctrlKey && !e.metaKey && (!window.getSelection().toString() || window.getSelection().toString() == "") && !e.target.closest('button') && !e.target.closest('figure') && !e.target.closest('.dropdown') && !e.target.closest('[data-id=activity_actions]')
)) {
let uri = this.el.dataset.href || (trigger !== undefined && trigger.getAttribute('href'))
if (window.liveSocket) {
// const feed = document.querySelector(".feed")
const main = document.getElementById("inner")
const layout = document.getElementById("root")
const preview_content = document.getElementById("preview_content")
let previous_scroll = null

console.log("push event to load up the PreviewContent")
this.pushEventTo(trigger, "open", {})

// this.pushEvent("Bonfire.Social.Feeds:open_activity", { id: this.el.dataset.id, permalink: uri })

if (layout) {
previous_scroll = layout.scrollTop
}

if (preview_content) {
preview_content.classList.remove("hidden")
}
if (main) {
main.classList.add("hidden")
}
if (uri) {
// console.log(uri)

history.pushState(
{
'previous_url': document.location.href,
'previous_scroll': previous_scroll
},
'',
uri)
}

// this was used to expand long posts by clicking on them, now replaced with a 'Read more' button
// let previewable_activity = e.target.closest('.previewable_activity')
// anchor == trigger || (!anchor && previewable_activity && ( previewable_activity.classList.contains('previewable_expanded') || this.isTruncated(previewable_activity.querySelector('.previewable_truncate')) == false)

if (trigger && ((!anchor || anchor.classList.contains('preview_activity_link')) && !e.ctrlKey && !e.metaKey && !window.getSelection().toString() && !e.target.closest('button') && !e.target.closest('figure') && !e.target.closest('.dropdown') && !e.target.closest('[data-id=activity_actions]')
)) {
let uri = this.el.dataset.href || (trigger !== undefined && trigger.getAttribute('href')) //this.el.dataset.permalink
if (window.liveSocket) {
// const feed = document.querySelector(".feed")
const main = document.getElementById("inner")
const layout = document.getElementById("root")
const preview_content = document.getElementById("preview_content")
let previous_scroll = null

console.log("push event to load up the PreviewContent")
this.pushEventTo(trigger, "open", {})
e.preventDefault();

// this.pushEvent("Bonfire.Social.Feeds:open_activity", { id: this.el.dataset.id, permalink: uri })
} else {

if (layout) {
previous_scroll = layout.scrollTop
}
// fallback if not connected with live socket

if (preview_content) {
preview_content.classList.remove("hidden")
if (uri) {
console.log(uri)
window.location = uri;
e.preventDefault();
} else {
console.log("No URL")
}
}
if (main) {
main.classList.add("hidden")
}
if (uri) {
// console.log(uri)

history.pushState(
{
'previous_url': document.location.href,
'previous_scroll': previous_scroll
},
'',
uri)
}

e.preventDefault();

} else {

// fallback if not connected with live socket

if (uri) {
console.log(uri)
window.location = uri;
e.preventDefault();
} else {
console.log("No URL")
}
}

} else {

// e.preventDefault();

console.log("PreviewActivity: do not trigger preview in favour of another link or button's action (or opening in new tab)")

// if (previewable_activity) { previewable_activity.classList.add("previewable_expanded") }
console.log(trigger)
console.log(window.liveSocket)
console.log(anchor)
console.log(anchor.classList)
console.log(e.ctrlKey)
console.log(e.metaKey)
console.log(window.getSelection().toString())
console.log(e.target.closest('button'))
console.log(e.target.closest('figure'))
console.log(e.target.closest('.dropdown'))
console.log(e.target.closest('[data-id=activity_actions]'))

// if (previewable_activity) { previewable_activity.classList.add("previewable_expanded") }

return;
return;

}
}




})
}
Expand Down
Loading

0 comments on commit 73cfe18

Please sign in to comment.