-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Social | Migrate shares data from initial state to new script data (#…
…38988) * Social | Migrate shares data from initial state to new script data * Add changelog * Fix the export
- Loading branch information
1 parent
e2e6b98
commit bae165e
Showing
15 changed files
with
87 additions
and
161 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
...s-packages/publicize-components/changelog/update-social-initial-state-migrate-shares-data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: changed | ||
|
||
Social: Migrated shares data to the new script data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
projects/js-packages/publicize-components/src/social-store/reducer/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
projects/js-packages/publicize-components/src/social-store/reducer/shares-data.js
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
projects/js-packages/publicize-components/src/social-store/selectors/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 0 additions & 47 deletions
47
projects/js-packages/publicize-components/src/social-store/selectors/shares-data.ts
This file was deleted.
Oops, something went wrong.
73 changes: 0 additions & 73 deletions
73
...ects/js-packages/publicize-components/src/social-store/selectors/test/shares-data.test.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
projects/js-packages/publicize-components/src/utils/shares-data.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { getSocialScriptData } from './script-data'; | ||
|
||
/** | ||
* Returns the shares data. | ||
* | ||
* @return {import('../types/types').SharesData} Shares data | ||
*/ | ||
export function getSharesData() { | ||
return getSocialScriptData().shares_data; | ||
} | ||
/** | ||
* Returns the total number of shares already used. | ||
* | ||
* @return {number} Total number of shares used | ||
*/ | ||
export function getSharesUsedCount() { | ||
return getSharesData().publicized_count ?? 0; | ||
} | ||
|
||
/** | ||
* Returns the number of shares scheduled. | ||
* | ||
* @return {number} Number of shares scheduled | ||
*/ | ||
export function getScheduledSharesCount() { | ||
return getSharesData().to_be_publicized_count ?? 0; | ||
} | ||
|
||
/** | ||
* Returns the total number of shares used and scheduled. | ||
* | ||
* @return {number} Total number of shares used and scheduled | ||
*/ | ||
export function getTotalSharesCount() { | ||
const count = getSharesUsedCount() + getScheduledSharesCount(); | ||
|
||
return Math.max( count, 0 ); | ||
} | ||
|
||
/** | ||
* Number of posts shared this month | ||
* | ||
* @return {number} Number of posts shared this month | ||
*/ | ||
export function getSharedPostsCount() { | ||
return getSharesData().shared_posts_count ?? 0; | ||
} |
4 changes: 4 additions & 0 deletions
4
projects/packages/publicize/changelog/update-social-initial-state-migrate-shares-data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: changed | ||
|
||
Social: Migrated shares data to the new script data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
projects/plugins/social/changelog/update-social-initial-state-migrate-shares-data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: changed | ||
|
||
Social: Migrated shares data to the new script data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters